57 lines
1.4 KiB
PHP
57 lines
1.4 KiB
PHP
<?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');
|
|
}
|
|
}
|