-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add verified middleware * Add resend verification mail and must verify mail to access user dashboard * Fix code style * Add tests for unverifiedUser * Apply suggestions from code review Co-authored-by: Kamil Piech <[email protected]> * Fix misspelled word * Add redirect to home page if user tries to verify email via mail and is not logged in. Add automatic log in after registration --------- Co-authored-by: Kamil Piech <[email protected]>
- Loading branch information
1 parent
d600a31
commit 9986a09
Showing
5 changed files
with
59 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<script setup lang="ts"> | ||
import {useForm} from '@inertiajs/vue3' | ||
const form = useForm({}) | ||
function logout() { | ||
form.get('/auth/logout') | ||
} | ||
function sent() { | ||
form.post('/email/verification-notification') | ||
} | ||
</script> | ||
|
||
<template> | ||
<form @submit.prevent="sent"> | ||
<button type="submit">Wyślij ponownie link weryfikacyjny</button> | ||
</form> | ||
|
||
<form @submit.prevent="logout"> | ||
<button type="submit">Logout</button> | ||
</form> | ||
</template> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,4 +58,22 @@ public function testUserCanNotLoginWithEmptyEmailAndPassword(): void | |
->assertRedirect("/test") | ||
->assertSessionHasErrors(["email" => "Pole e-mail jest wymagane.", "password" => "Pole hasło jest wymagane."]); | ||
} | ||
|
||
public function testUnverifiedUserCanLogin(): void | ||
{ | ||
User::factory()->unverifiedUser()->create(["email" => "[email protected]", "password" => "goodPassword"]); | ||
$this->from("/")->post("/auth/login", [ | ||
"email" => "[email protected]", | ||
"password" => "goodPassword", | ||
]) | ||
->assertRedirect("/dashboard"); | ||
} | ||
|
||
public function testUnverifiedUserIsRedirectedToVerifyEmail(): void | ||
{ | ||
$user = User::factory()->unverifiedUser()->create(); | ||
$this->actingAs($user) | ||
->get("/dashboard") | ||
->assertRedirect("/email/verify"); | ||
} | ||
} |