成功登录后中间件未执行

时间:2017-11-25 14:29:34

标签: laravel-5.2

AdminMiddleware:

public function handle($request, Closure $next)
{
    return $next($request);

    if (\Auth::user() && \Auth::user()->isAdmin() == 1) {
            return view('adminpage');
        } else {
            return view('homepage');
        }
    }
}

user.php的:

public function isAdmin() {
    return $this->is_admin;
}

UserController.php:

public function login(Request $request)
{
    $email = $request->email;
    $password = $request->password;

    if(\Auth::attempt(['email'=>$email, 'password'=>$password])) {
        // i dont know what if successfull login, i need to execute the logic written in AdminMiddleware
    } else {
        return view('login);
    }
}

我的表包含一个布尔字段" is_admin"使用1 xxx@gmail.com

0 个答案:

没有答案