'Invalid Password', 'errors' => [] ]; if( $request->header('X-API-PASSWORD') ) { if(!Hash::check($request->header('X-API-PASSWORD'), auth()->user()->password)) return response()->json($error, 403); } elseif (Cache::get(auth()->user()->email."_logged_in")) { return $next($request); } else { $error = [ 'message' => 'Access denied', 'errors' => [] ]; return response()->json($error, 412); } Cache::add(auth()->user()->email."_logged_in", Str::random(64), now()->addMinutes(10)); return $next($request); } }