- Update login management
This commit is contained in:
parent
482f814c7b
commit
c411153dca
1 changed files with 30 additions and 10 deletions
|
|
@ -196,18 +196,38 @@ class CustomerController extends Controller
|
|||
if ($customer) {
|
||||
$login = $customer->logins()->where('brand_id', $brandId)->first();
|
||||
if ($login) {
|
||||
if ($login->status === 0) {
|
||||
// "Le compte de l'utilisateur n'est pas activé"
|
||||
return new StatusResource(['status' => 'KO', 'code' => 116, 'message' => 'Account not activated.']);
|
||||
} else {
|
||||
if (Hash::check($password, $login->password)) {
|
||||
$login->last_connection = now();
|
||||
$customer->logins()->save($login);
|
||||
return new CustomerResource($customer, $brandId);
|
||||
if (Hash::check($password, $login->password)) {
|
||||
if ($login->status === 0) {
|
||||
// "Le compte de l'utilisateur n'est pas activé"
|
||||
return new StatusResource(
|
||||
[
|
||||
'status' => 'KO',
|
||||
'code' => 116,
|
||||
'message' => 'Account not activated.',
|
||||
'user' => [
|
||||
'crm_id' => $customer->id,
|
||||
'firstname' => $customer->infos()->firstname,
|
||||
'lastname' => $customer->infos()->lastname,
|
||||
'birth_date' => $customer->infos()->birth_date,
|
||||
'address' => $customer->infos()->address,
|
||||
'address2' => $customer->infos()->address2,
|
||||
'phone' => $customer->infos()->phone,
|
||||
'country' => $customer->infos()->country,
|
||||
'city' => $customer->infos()->city,
|
||||
'postcode' => $customer->infos()->postcode,
|
||||
'opt_in' => $customer->infos()->opt_in,
|
||||
'hashcode' => $customer->infos()->hashcode,
|
||||
'status' => $login->status,
|
||||
]
|
||||
]);
|
||||
}
|
||||
// "Mot de passe incorrect"
|
||||
return new StatusResource(['status' => 'KO', 'code' => 117, 'message' => 'Authentication failed.']);
|
||||
|
||||
$login->last_connection = now();
|
||||
$customer->logins()->save($login);
|
||||
return new CustomerResource($customer, $brandId);
|
||||
}
|
||||
// "Mot de passe incorrect"
|
||||
return new StatusResource(['status' => 'KO', 'code' => 117, 'message' => 'Authentication failed.']);
|
||||
} else {
|
||||
// "Ce compte n'est pas enregistré pour cette marque"
|
||||
return new StatusResource(['status' => 'KO', 'code' => 118, 'message' => 'User not found.']);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue