diff --git a/app/Http/Middleware/UserVerified.php b/app/Http/Middleware/UserVerified.php new file mode 100644 index 0000000000..35a0acdeea --- /dev/null +++ b/app/Http/Middleware/UserVerified.php @@ -0,0 +1,52 @@ +user = $user ?: auth()->user(); + } + + /** + * Handle an incoming request. + * + * @param Request $request + * @param Closure $next + * @return mixed + */ + public function handle($request, Closure $next) + { + + $error = [ + 'message' => 'Email confirmation required.', + 'errors' => new \stdClass, + ]; + + if ($this->user && !$this->user->isVerified()) + return response()->json($error, 403); + + return $next($request); + } +}