Home Laravel Passport - Column Validation Overrides

Enter a search term to find articles.
laravel-passport-column-validation-overrides
2019-07-08
347

Laravel Passport - Column Validation Overrides

When using Laravel Passport, you can override the columns that you use to validate username and password for password grant clients (default is email and password) by adding these methods on your User model.

// Within your User model, add the following methods..

use Illuminate\Support\Facades\Hash;

...

public function findForPassport($username)
{
    return $this->where('other_username_column', $username)->first();
}

public function validateForPassportPasswordGrant($password)
{
    return Hash::check($password, $this->some_other_password_attribute);
}

Source: Laravel\Passport\Bridge\UserRepository@getUserEntityByUserCredentials

Marvin Quezon

Full Stack Web Developer
Marvin Quezon · Copyright © 2024 · Privacy · Sitemap