在 laravel 中覆盖登录身份验证
Override login Authentication in laravel
我的 laravel
版本是 5.3
。我在 laravel
中使用内置身份验证来登录用户。
用户 table 中有一个列名为 status
。当它是 0
时,表示用户无法登录。
现在我不知道如何在登录前检查此列method/user。
当 status
列为 0
.
时,我不希望用户可以登录
您可以覆盖 authenticated()
函数:
protected function authenticated()
{
if (auth()->user()->status==0) {
auth()->logout();
return redirect('/');
}
}
您还可以 Manually authenticate users 通过覆盖 authenticate()
函数:
public function authenticate()
{
if (Auth::attempt(['email' => $email, 'password' => $password, 'status' => 1]))
{
// Authentication passed...
}
}
我的 laravel
版本是 5.3
。我在 laravel
中使用内置身份验证来登录用户。
用户 table 中有一个列名为 status
。当它是 0
时,表示用户无法登录。
现在我不知道如何在登录前检查此列method/user。
当 status
列为 0
.
您可以覆盖 authenticated()
函数:
protected function authenticated()
{
if (auth()->user()->status==0) {
auth()->logout();
return redirect('/');
}
}
您还可以 Manually authenticate users 通过覆盖 authenticate()
函数:
public function authenticate()
{
if (Auth::attempt(['email' => $email, 'password' => $password, 'status' => 1]))
{
// Authentication passed...
}
}