Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…into 12-dashboard
  • Loading branch information
AmonDeShir committed Sep 6, 2024
2 parents 80b327f + a7bf744 commit 2e8076b
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
6 changes: 4 additions & 2 deletions app/Http/Controllers/EmailVerifyController.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@ 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!");
->with("status", "Wiadomość z linkiem aktywacyjnym została wysłana na Twój adres e-mail!");
}
}
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");
}
}
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

0 comments on commit 2e8076b

Please sign in to comment.