diff --git a/src/Illuminate/Auth/Middleware/EnsureEmailIsVerified.php b/src/Illuminate/Auth/Middleware/EnsureEmailIsVerified.php index f9ee4babce57..54b8c7ff3807 100644 --- a/src/Illuminate/Auth/Middleware/EnsureEmailIsVerified.php +++ b/src/Illuminate/Auth/Middleware/EnsureEmailIsVerified.php @@ -13,14 +13,18 @@ class EnsureEmailIsVerified * * @param \Illuminate\Http\Request $request * @param \Closure $next - * @return \Illuminate\Http\Response + * @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse */ public function handle($request, Closure $next) { if (! $request->user() || ($request->user() instanceof MustVerifyEmail && ! $request->user()->hasVerifiedEmail())) { - return Redirect::route('verification.notice'); + if ($request->expectsJson()) { + abort(403, 'Your email address is not verified.'); + } else { + return Redirect::route('verification.notice'); + } } return $next($request);