I\'m trying to apply Laravel-5.7 MustVerifyEmail on multiple authentication system. So far what I\'ve done is as follows:
Finally, after four days of research I was able to solve the issue.
I altered the "EnsureEmailIsVerified" middleware as follows:
check()) {
if (! Auth::guard($guard)->user() ||
(Auth::guard($guard)->user() instanceof MustVerifyEmail &&
! Auth::guard($guard)->user()->hasVerifiedEmail())) {
return $request->expectsJson()
? abort(403, 'Your email address is not verified.')
: Redirect::route('admin.verification.notice');
}
}
}
elseif ($guard == 'auditor') {
if (Auth::guard($guard)->check()) {
if (! Auth::guard($guard)->user() ||
(Auth::guard($guard)->user() instanceof MustVerifyEmail &&
! Auth::guard($guard)->user()->hasVerifiedEmail())) {
return $request->expectsJson()
? abort(403, 'Your email address is not verified.')
: Redirect::route('auditor.verification.notice');
}
}
}
elseif ($guard == 'web') {
if (Auth::guard($guard)->check()) {
if (! Auth::guard($guard)->user() ||
(Auth::guard($guard)->user() instanceof MustVerifyEmail &&
! Auth::guard($guard)->user()->hasVerifiedEmail())) {
return $request->expectsJson()
? abort(403, 'Your email address is not verified.')
: Redirect::route('verification.notice');
}
}
}
}
return $next($request);
}
}
And that's solved my problem.