2017-05-25 115 views
0

在Laravel代码src \照射\基金会\身份验证\ AuthenticatesUsers.php,有一种方法如下 -

protected function authenticated(Request $request, $user) 
    { 
     // 
    } 

这种方法似乎是重定向登录的用户的欢迎登录的用户页面,但方法是空白的。当我在这个方法中插入'return'hello user';'那么该页面显示'你好用户'。我想改变这种方法重定向到一个自定义的网址,并想知道我能在哪里做出更改,并研究与此方法相关的其他代码。我很难找到我正在寻找的正确代码。

编辑:上述方法用于此方法中的三元代码中的相同文件中。我试图找出他们如何一起工作 -

protected function sendLoginResponse(Request $request) 
    { 
     $request->session()->regenerate(); 

     $this->clearLoginAttempts($request); 

     return $this->authenticated($request, $this->guard()->user()) 
       ?: redirect()->intended($this->redirectPath()); 
    } 
+0

你不应该在你的'src \ illuminate \ Foundation \ Auth \ AuthenticatesUsers.php'中弄乱它,它是核心laravel文件 –

+0

嘿Nikhil,你能帮我一下吗? - https://stackoverflow.com/questions/44174928/laravel-5-4-how-do-i-redirect-logged-in-users-to-referral-url-after-successful –

+0

可能重复的[Laravel 5.4,如何在成功登录后将登录用户重定向到引用URL?](https://stackoverflow.com/questions/44174928/laravel-5-4-how-do-i-redirect-logged-in-users-to-转诊网址后成功) – linktoahref

回答

1

这是因为处理该方法继承特质.. 如果你想在成功登录的自定义功能的类..你可以做什么不使用laravel登录功能..你可以做使用验证门面自己的登录..

在你的LoginController例如

function myOwnLogin(Request $request) 
{ 
    $credentials= $request->only('username', 'password'); 
    if(Auth::attempt($appGrantCreds)) 
    { 
     // in this block the user is already authenticated using username and password .. 
     // so you can do your functionality here and whatsoever 
    } 
    else 
    { 
     // do your functionality for unsuccessful login 
    } 
} 

,也不要忘记设置$redirectTo = '/yourDesiredRoute';

相关问题