0
中的用户我想在登录到我的网站时执行自定义重定向逻辑。所以我写了这个代码在Laravel 5.3中创建自定义重定向逻辑;无法登录
public function login()
{
$user = //what do I put here?
$this->guard()->login($user);
$id = Auth::id();
//dd($id);
$rfid = DB::table('users')->where('id', $id)->value('reference_id');
if ($rfid == null){
dd($id);
return redirect()->action('[email protected]');
}
else {
//dd($rfid);
return redirect()->action('[email protected]');
}
}
但我的问题是,它是所有重定向。这是有道理的。我有代码只管理重定向,没有什么有实际登录的人。所以我做了一些研究和发现
$this->guard()->login($user);
,以此来登录的用户。不过,我不知道是什么将变量$ user定义为。我知道这应该工作,因为我在我的网站上的另一个地方使用它,但它使用的$用户变量不会在这里工作。因此,在用户简单登录的情况下,为了授权用户和我们的数据库一样,在那里放置了什么,然后登录?
我会给你一个去。我还发现这个http://stackoverflow.com/questions/39532803/laravel-5-3-custom-path-for-post-authentication-redirect并将我的代码更改为如下所示。 https://gyazo.com/e6446cc3fc81a0fbe54cdda82c9461f3 你会建议我保持我现在所拥有的(就我所知而言)或者使用你的方法吗? – Albure
我个人不喜欢从核心框架方法转移太多,直到完全有必要。重写包含定制的方法是很好的选择。 –
用你以上的话继续? – Albure