账号锁定后,5分钟后自动解锁

main
Jing Li 2024-06-02 20:40:59 +08:00
parent 31e20d139c
commit 470c9c25c9
1 changed files with 8 additions and 4 deletions

View File

@ -33,11 +33,15 @@ class AuthController extends Controller
$user = AdminUser::where(['username' => $username])->first();
$cacheKey = "admin_user_ban:{$username}";
if ($user?->banned_at) {
if ($user->banned_at->addMinutes(5)->gte(now())) {
return $this->error('账号已封禁,请联系管理员');
}
$cacheKey = "admin_user_ban:{$username}";
$this->cache->forget($cacheKey);
}
if (! Hash::check($request->input('password'), (string) $user?->password)) {
$this->cache->add($cacheKey, 0, 86400);