diff --git a/app/Http/Controllers/AuthController.php b/app/Http/Controllers/AuthController.php index 740edce..65bed81 100644 --- a/app/Http/Controllers/AuthController.php +++ b/app/Http/Controllers/AuthController.php @@ -59,6 +59,12 @@ class AuthController extends Controller ]); } + if (! $user->hasVerifiedEmail()) { + throw ValidationException::withMessages([ + 'email' => [__('auth.email_not_verified')], + ]); + } + $token = $user->createToken( $this->resolveDeviceName($data) )->plainTextToken; diff --git a/lang/en/auth.php b/lang/en/auth.php index 5a16e20..2d84262 100644 --- a/lang/en/auth.php +++ b/lang/en/auth.php @@ -19,6 +19,8 @@ return [ 'logout_success' => 'You have been deconnecte', 'email_verified' => 'Email address verified.', 'email_already_verified' => 'Email address already verified.', + 'email_not_verified' => 'Please verify your email address before logging in.', 'email_verification_sent' => 'Verification link sent.', + 'soft_delete_success' => 'Your Account has been successfully deleted.', ]; diff --git a/lang/fr/auth.php b/lang/fr/auth.php index 9f84dfd..22fd8cd 100644 --- a/lang/fr/auth.php +++ b/lang/fr/auth.php @@ -16,9 +16,11 @@ return [ 'failed' => 'Impossible de vous connecter', 'password' => 'Email ou mot de passe incorrect', 'throttle' => 'Trop de tentatives veuillez reessayer dans :seconds seconds.', - 'logout_success' => 'Vous êtes bien déconnecté', + 'logout_success' => 'Vous êtes bien déconnecté.', 'email_verified' => 'Adresse email vérifiée.', 'email_already_verified' => 'Adresse email déjà vérifiée.', + 'email_not_verified' => 'Veuillez vérifier votre adresse email avant de vous connecter.', 'email_verification_sent' => 'Lien de vérification envoyé.', + 'soft_delete_success' => 'Votre compte à bien été supprimé.', ]; diff --git a/tests/Feature/Auth/LoginTest.php b/tests/Feature/Auth/LoginTest.php new file mode 100644 index 0000000..f54e7c7 --- /dev/null +++ b/tests/Feature/Auth/LoginTest.php @@ -0,0 +1,23 @@ +unverified()->create([ + 'password' => 'password', + ]); + + $response = $this->postJson('/api/auth/login', [ + 'email' => $user->email, + 'password' => 'password', + ]); + + $response + ->assertUnprocessable() + ->assertJsonValidationErrors([ + 'email' => __('auth.email_not_verified'), + ]); +});