php - 我的 Laravel Auth::attempt() 函数不起作用
问题描述
这是我的控制器
if($request->isMethod('post')){
$data = $request->input();
if(Auth::attempt(['email'=>$data['username'],'password'=>$data['password'],'user_type'=>'2'])){
return redirect('/business/dashboard');
解决方案
尝试使用此代码:如果 user_type 列类型为整数,则给出不带引号的 2 否则相同的代码和密码必须是 hash::make 否则 auth::attempt 将不起作用。
if($request->isMethod('post')){
$user = User::where(['email'=>$request['username'],'user_type'=>'2'])->first();
if(!empty($user)){
if(Auth::attempt(['email'=>$request['username'],'password'=>$request['password']])){
return redirect('/business/dashboard');
}
abort(404);
推荐阅读
- java - 使用活动之间的先前数据重新加载 recyclerView
- javascript - 我该如何解决这个问题?未捕获的类型错误:无法读取 HTMLButtonElement.botonContinuar.onclick 处未定义的属性“textContent”
- java - 在 Java 中的 Scanner 中包含空格
- php - 按钮使一行处于活动状态,其他行处于非活动状态
- c# - Response.Redirect() 问题
- influxdb - 如何从 InfluxDB 1.8 升级到 2.0
- python - 当我附加很多图像时,为什么我的列表/数组的维度会发生变化?
- swift - Firebase observe.value 不附加数组
- python - 如何查看我的神经网络在 python tensorflow 中丢失的训练样本
- html - CSS max-width 的像素精度不准确