Laravel中自定义guard,自定义Auth的attempt方法

简介: 这个今天算是踩到坑了。 将普通用户和管理员用户分别放在不同的表里。 那么,前台和后台登陆时, 认证的东东就要分开。 开始还顺利, 等认证完成之后, 却无法获取登陆的用户。

这个今天算是踩到坑了。

将普通用户和管理员用户分别放在不同的表里。

那么,前台和后台登陆时,

认证的东东就要分开。

开始还顺利,

等认证完成之后,

却无法获取登陆的用户。


卡了一小时,找到讲法,

Auth后要带自定义的guard,才可以得到正确的登陆用户。

OMG。。




if (Auth::guard('admin')->attempt(['email' => $data['email'], 
            'pwd' => $data['pwd'], 
            'auth' => xxx],FALSE)) {
            return redirect()->route('index');
        } else {
            return back()->with('error','用户名密码错误');
        }



if(Auth::guard('admin')->check()){
            //进入下一层
            return $next($request);
        }else{
            return response()->view('login');

        }   


目录
相关文章
|
运维 JavaScript jenkins
uni-app命令行构建Module parse failed:Unexpected token错误处理
分享一次打包环境升级导致的jenkins部署流程失败问题的解决过程。
1496 0
|
6月前
【异常解决】postman请求提示Full authentication is required to access this resource
【异常解决】postman请求提示Full authentication is required to access this resource
84 0
|
8月前
|
安全 PHP
PHP - Laravel 表单验证(验证规则与使用 $this->validate()、Validator::make()、Requests)
PHP - Laravel 表单验证(验证规则与使用 $this->validate()、Validator::make()、Requests)
146 0
|
9月前
fastadmin中Validate和validate的区别
fastadmin中Validate和validate的区别
112 0
|
9月前
|
存储 JSON UED
Flask框架之RESTful--参数验证--add_argument方法参数详解
参数验证的重要性,Flask-RESTful 参数验证方法,add_argument方法参数详解
|
NoSQL MongoDB PHP
Yii2使用Mongodb配置并解决SyntaxError: missing ] after element list以及Authentication failed
Yii2使用Mongodb配置并解决SyntaxError: missing ] after element list以及Authentication failed
263 0
Yii2使用Mongodb配置并解决SyntaxError: missing ] after element list以及Authentication failed
|
缓存 中间件 API
【laravel】 Unable to prepare route [api/user] for serialization. Uses Closure.
【laravel】 Unable to prepare route [api/user] for serialization. Uses Closure.
523 0
【laravel】 Unable to prepare route [api/user] for serialization. Uses Closure.
|
PHP
【laravel报错】You don‘t have permission to access /laravel/public/index.php on this server.
【laravel报错】You don‘t have permission to access /laravel/public/index.php on this server.
97 0
【laravel报错】You don‘t have permission to access /laravel/public/index.php on this server.
|
测试技术
Appium问题解决方案(5)- selenium.common.exceptions.InvalidSelectorException: Message: Locator Strategy 'name' is not supported for this session
Appium问题解决方案(5)- selenium.common.exceptions.InvalidSelectorException: Message: Locator Strategy 'name' is not supported for this session
418 0
Appium问题解决方案(5)- selenium.common.exceptions.InvalidSelectorException: Message: Locator Strategy 'name' is not supported for this session
SAP Spartacus config-initializer.service.ts get isStable属性失败的调试
SAP Spartacus config-initializer.service.ts get isStable属性失败的调试
103 0
SAP Spartacus config-initializer.service.ts get isStable属性失败的调试