feat: resend email
# Conflicts: # app/Http/Controllers/AuthController.php # lang/en/api.php # lang/fr/api.php # tests/Feature/EmailVerificationTest.php
This commit is contained in:
@@ -101,19 +101,40 @@ it('allows login for verified users', function () {
|
||||
->assertCookie('token');
|
||||
});
|
||||
|
||||
it('resends a verification email for an authenticated unverified user', function () {
|
||||
it('resends a verification email for an unverified user without authentication', function () {
|
||||
Notification::fake();
|
||||
|
||||
$user = User::factory()->unverified()->create();
|
||||
Sanctum::actingAs($user);
|
||||
|
||||
$this->postJson('/api/auth/email/verification-notification')
|
||||
$this->postJson('/api/auth/email/verification-notification', [
|
||||
'email' => $user->email,
|
||||
])
|
||||
->assertOk()
|
||||
->assertJsonPath('message', __('api.auth.verification_sent'));
|
||||
->assertJsonPath('message', __('api.auth.verification_sent_if_unverified'));
|
||||
|
||||
Notification::assertSentTo($user, VerifyEmail::class);
|
||||
});
|
||||
|
||||
it('does not reveal whether an email can receive a verification email', function () {
|
||||
Notification::fake();
|
||||
|
||||
$verifiedUser = User::factory()->create();
|
||||
|
||||
$this->postJson('/api/auth/email/verification-notification', [
|
||||
'email' => $verifiedUser->email,
|
||||
])
|
||||
->assertOk()
|
||||
->assertJsonPath('message', __('api.auth.verification_sent_if_unverified'));
|
||||
|
||||
$this->postJson('/api/auth/email/verification-notification', [
|
||||
'email' => 'missing@example.com',
|
||||
])
|
||||
->assertOk()
|
||||
->assertJsonPath('message', __('api.auth.verification_sent_if_unverified'));
|
||||
|
||||
Notification::assertNothingSent();
|
||||
});
|
||||
|
||||
it('blocks verified routes for unverified users', function () {
|
||||
$user = User::factory()->unverified()->create();
|
||||
Sanctum::actingAs($user);
|
||||
|
||||
Reference in New Issue
Block a user