Laravel Passport - Column Validation Overrides

Laravel Passport - Column Validation Overrides

July 8, 2019
491 views

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

Marvin Quezon

Full Stack Web Developer

Marvin Quezon · Copyright © 2025 · Privacy · Sitemap