feat: add optional email verification flow
This commit is contained in:
56
app/Http/Controllers/Auth/EmailVerificationController.php
Normal file
56
app/Http/Controllers/Auth/EmailVerificationController.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Foundation\Auth\EmailVerificationRequest;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Inertia\Inertia;
|
||||
use Inertia\Response;
|
||||
|
||||
class EmailVerificationController extends Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
if (! config('auth-ui.features.email_verification')) {
|
||||
abort(404);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the email verification notice.
|
||||
*/
|
||||
public function notice(Request $request): Response|RedirectResponse
|
||||
{
|
||||
if ($request->user()->hasVerifiedEmail()) {
|
||||
return redirect()->intended(config('auth-ui.redirects.login', '/'));
|
||||
}
|
||||
|
||||
return Inertia::render('Auth/VerifyEmail');
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the email verification.
|
||||
*/
|
||||
public function verify(EmailVerificationRequest $request): RedirectResponse
|
||||
{
|
||||
$request->fulfill();
|
||||
|
||||
return redirect()->intended(config('auth-ui.redirects.login', '/'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Resend the email verification notification.
|
||||
*/
|
||||
public function resend(Request $request): RedirectResponse
|
||||
{
|
||||
if ($request->user()->hasVerifiedEmail()) {
|
||||
return redirect()->intended(config('auth-ui.redirects.login', '/'));
|
||||
}
|
||||
|
||||
$request->user()->sendEmailVerificationNotification();
|
||||
|
||||
return back()->with('status', 'verification-link-sent');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user