Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#60 - User do not get info about bad email in registration form #77

7 changes: 6 additions & 1 deletion app/Http/Controllers/EmailVerifyController.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,12 @@ public function create(): Response

public function send(Request $request): RedirectResponse
{
$request->user()->sendEmailVerificationNotification();
if (auth()->check()) {
$request->user()->sendEmailVerificationNotification();

return back()
->with("message", "Wiadomość z linkiem aktywacyjnym została wysłana na Twój adres e-mail!");
}

return back()
->with("message", "Wiadomość z linkiem aktywacyjnym została wysłana na Twój adres e-mail!");
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/RegisterUserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ public function store(RegisterUserRequest $request): RedirectResponse
Auth::login($user);
}

return Redirect::route("home");
return Redirect::route("verification.notice");
}
}
2 changes: 1 addition & 1 deletion resources/js/Layouts/AdminLayout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ if (props.user?.isSuperAdmin) {
</script>

<template>
<BaseLayout :pages :app-name="appName" name :user :flash>
<BaseLayout :pages :app-name="appName" :user :flash>
<slot />
</BaseLayout>
</template>
2 changes: 2 additions & 0 deletions resources/js/Pages/Auth/Verify-Email.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ function logout() {
}

function sent() {


PrabuckiDominik marked this conversation as resolved.
Show resolved Hide resolved
form.post('/email/verification-notification')
}

Expand Down
4 changes: 2 additions & 2 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
use App\Models\Question;
use Illuminate\Support\Facades\Route;

Route::get("/email/verify", [EmailVerifyController::class, "create"])->middleware("auth")->name("verification.notice");
Route::get("/email/verify", [EmailVerifyController::class, "create"])->name("verification.notice");
Route::get("/email/{id}/{hash}", EmailVerifyController::class)->middleware(["auth", "throttle:6,1"])->name("verification.verify");
Route::post("/email/verification-notification", [EmailVerifyController::class, "send"])->middleware("auth", "throttle:3,60")->name("verification.send");
Route::post("/email/verification-notification", [EmailVerifyController::class, "send"])->middleware("throttle:3,60")->name("verification.send");
Route::post("/auth/logout", [AuthenticateSessionController::class, "logout"])->middleware("auth")->name("logout");

Route::middleware(["guest"])->group(function (): void {
Expand Down
8 changes: 5 additions & 3 deletions tests/Feature/RegisterUserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function testUserCanRegister(): void
"password" => "123456890",
"school_id" => $school->id,
])
->assertRedirect("/");
->assertRedirect("/email/verify");

$this->assertDatabaseHas("users", [
"name" => "Test",
Expand All @@ -39,7 +39,7 @@ public function testUserCanRegister(): void
]);
}

public function testUserCanNotCheckIfEmailIsAlreadyTakenViaRegisterForm(): void
public function testUserIsRedirectedToEmailVerifyIfEmailIsAlreadyTakenViaRegisterForm(): void
{
$school = School::factory()->create();
User::factory()->create([
Expand All @@ -53,7 +53,9 @@ public function testUserCanNotCheckIfEmailIsAlreadyTakenViaRegisterForm(): void
"password" => "123456890",
"school_id" => $school->id,
])
->assertRedirect("/");
->assertRedirect("/email/verify");

$this->assertGuest();
}

public function testUserCanNotRegisterWithWrongSchoolIndex(): void
Expand Down
Loading