middleware('auth'); $this->middleware('signed')->only('verify'); $this->middleware('throttle:6,1')->only('verify', 'resend'); } /** * Display the email verification notice. */ public function show(Request $request): InertiaResponse|RedirectResponse { return $request->user()->hasVerifiedEmail() ? redirect($this->redirectTo) : Inertia::render('auth/VerifyEmail', [ 'resent' => (bool) $request->session()->get('resent'), ]); } /** * Mark the authenticated user's email address as verified. * * @throws AuthorizationException */ public function verify(Request $request): RedirectResponse|JsonResponse { if (! hash_equals((string) $request->route('id'), (string) $request->user()->getKey())) { throw new AuthorizationException; } if (! hash_equals((string) $request->route('hash'), sha1($request->user()->getEmailForVerification()))) { throw new AuthorizationException; } if ($request->user()->hasVerifiedEmail()) { return $request->wantsJson() ? new JsonResponse([], 204) : redirect($this->redirectTo); } if ($request->user()->markEmailAsVerified()) { event(new Verified($request->user())); } return $request->wantsJson() ? new JsonResponse([], 204) : redirect($this->redirectTo)->with('verified', true); } /** * Resend the email verification notification. */ public function resend(Request $request): RedirectResponse|JsonResponse { if ($request->user()->hasVerifiedEmail()) { return $request->wantsJson() ? new JsonResponse([], 204) : redirect($this->redirectTo); } $request->user()->sendEmailVerificationNotification(); return $request->wantsJson() ? new JsonResponse([], 202) : back()->with('resent', true); } }