从laravel事件中解除重定向

时间:2016-01-08 15:20:30

标签: events redirect laravel-5.1

我的用户表格中有一个reset_password字段,该字段设置为' 1'创建用户帐户时当用户登录时,我会检查此字段,如果设置为' 1'在一个事件中。如果字段设置为' 1'。

,我想从事件重定向

我试过了:

return redirect()->route('user/change_password');

在我设置的路线文件中 Route::get('user/change_password', 'UserController@resetpasswordform');

但是这会返回以下错误: UrlGenerator.php第306行中的InvalidArgumentException:路径[user / change_password]未定义。

我也试过这个 return redirect()->action('UserController@resetpasswordform');

但这只是忽略重定向并将用户登录。我在方法中设置了dd('hello');,但这没有任何作用。

我尝试更改经过身份验证的用户的重定向,如果该字段未设置为1则遵循此重定向,但如果该字段设置为1则忽略此。

我对此重定向所采用的路线感到茫然

任何帮助非常感谢

2 个答案:

答案 0 :(得分:1)

我将postLogin类复制到我的AuthController并将方法转移到方法

if (Auth::attempt($credentials, $request->has('remember'))) {
    if(Auth::user()->reset_password=='1'){
        return redirect()->action('UserController@resetpasswordform');
    }

    return $this->handleUserWasAuthenticated($request, $throttles);
}

答案 1 :(得分:0)

return redirect('/user/change_password);

这对我有用,试试吧。