嗨,我已经使用 laravel 身份验证实现了 laravel 登录模块。我使用 Auth::check 对用户进行了身份验证,并在 Auth::attempt 方法中发送了用户名和密码。我在用户表中有状态列。
如何限制 Auth::check 仅验证状态为 1 的用户?
最佳答案
只需将状态字段设为确认之一即可。你可以这样做:
$credentials = array(
'username' => $input['email'],
'password' => $input['password'],
'status' => 1
);
if (Auth::attempt($credentials))
{
// User status is 1 and password was correct
}
如果你想明确地告诉用户他们不活跃——你可以这样跟进:
if (Auth::validate(['username' => $input['email'], 'password' => $input['password'], 'status' => 0]))
{
return echo ('you are not active');
}
关于php - 我们如何通过 Auth::check 在 laravel 4.2 中限制停用的用户,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27286581/