Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/laravel/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Laravel Nova:使用Passport进行身份验证_Laravel_Laravel Nova - Fatal编程技术网

Laravel Nova:使用Passport进行身份验证

Laravel Nova:使用Passport进行身份验证,laravel,laravel-nova,Laravel,Laravel Nova,如何配置Laravel Nova以使用Passport?目前,我可以通过常规/login(使用Auth中间件)路径登录我的应用程序,Nova管理部门将接受我的经过身份验证的用户,但是如果我尝试登录/Nova,它会声称“这些凭据与我们的记录不匹配” 我已经检查过了,但没有找到解决方案。我也有同样的问题。我不是100%确定这和你的问题是一样的,但我想我会分享,因为没有人提交答案 在我的例子中,我的用户模型上有一个setPasswordAttributemutator,用于在保存密码时对密码进行散列。

如何配置Laravel Nova以使用Passport?目前,我可以通过常规/login(使用Auth中间件)路径登录我的应用程序,Nova管理部门将接受我的经过身份验证的用户,但是如果我尝试登录/Nova,它会声称“这些凭据与我们的记录不匹配”


我已经检查过了,但没有找到解决方案。

我也有同样的问题。我不是100%确定这和你的问题是一样的,但我想我会分享,因为没有人提交答案

在我的例子中,我的用户模型上有一个
setPasswordAttribute
mutator,用于在保存密码时对密码进行散列。Nova已经对密码进行了哈希运算,因此它被哈希运算了两次。可能不是最好的解决方案,但我只是做了以下几点:

/** App\Models\User.php */
...
public function setPasswordAttribute($value)
{
    $password = starts_with($value, '$2y$') ? $value : Hash::make($value);
    $this->attributes['password'] = $password;
}

如果用户模型具有默认哈希密码的“setPasswordAttribute”,请在nova模型中使用此选项:

Password::make('Password'))
->onlyOnForms()
->creationRules('必需'、'字符串'、'最小值:6')
->updateRules('nullable','string','min:6')
->fillUsing(函数(NovaRequest$request、$model、$attribute、$requestAttribute){
如果(!empty($request->{$requestAttribute})){
$model->{$attribute}=$request[$requestAttribute];
}
}),