4

How can Laravel Nova be configured to work with Passport? Currently I can log into my application via the regular /login (using the Auth middleware) route and the Nova administration will accept my authenticated user, however if I attempt to login at /nova, it claims that "These credentials do not match our records."

I have reviewed https://github.com/laravel/nova-issues but have not found a solution.

AVProgrammer
  • 1,344
  • 2
  • 20
  • 40

2 Answers2

1

I had the same issue. I'm not 100% certain that it is the same as your problem, but I thought I would share since no one has submitted answer.

In my case, I have a setPasswordAttribute mutator on my User model to hash the password on save. Nova already hashes the password so it was being hashed twice. Probably not the best solution, but I just did the following:

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

If the User model has ‘setPasswordAttribute’ that hashes the password by default use this in the nova model:

Password::make('Password')
     ->onlyOnForms()
     ->creationRules('required', 'string', 'min:6')
     ->updateRules('nullable', 'string', 'min:6')
     ->fillUsing(function (NovaRequest $request, $model, $attribute, $requestAttribute) {
         if (! empty($request->{$requestAttribute})) {
             $model->{$attribute} = $request[$requestAttribute];
         }
     }),