gpt4 book ai didi

php - 如何在现有的默认身份验证上使用 Laravel 创建自定义身份验证

转载 作者:行者123 更新时间:2023-11-29 01:19:59 25 4
gpt4 key购买 nike

我目前正在完成我的工作,但我的客户需要更多关于管理用户的功能,例如暂停帐户或卡住帐户,我非常确定可以通过以下方式轻松完成:https://laravel.com/docs/5.4/authentication#authenticating-users ,但我已经在使用默认的 php artisan make:auth 身份验证。我的问题是,可以在用户登录时添加更多检查,例如 if active == true 或类似的东西?谢谢!

最佳答案

在 laravel 5.4 中,您可以使用 AuthenticatesUsersauthenticated post login hook 来进行自定义验证。

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

if($user->active){
return redirect()->intended($this->redirectPath());
}

$this->guard()->logout();

$request->session()->flush();

$request->session()->regenerate();

return redirect()->back()
->withInput($request->except('password'))
->withError('Please activate your account.')
}

关于php - 如何在现有的默认身份验证上使用 Laravel 创建自定义身份验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43424374/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com