Home > database >  login with different password column name in database
login with different password column name in database

Time:10-13

for some reason I had to deal with an old database table that contain users table. Password column is named as password_hash.

How can I login by using

Auth::attempt([....]) 

When it comes to login. I already know that we can override email with

public function username(){
   return 'username';
}

Is there any similar function to password? Thanks.

CodePudding user response:

This work for me.

Since my User model is extends Illuminate\Foundation\Auth\User and this class is use the Authenticatable trait, you can override the getAuthPassword() method,

public function getAuthPassword(){
    return $this->your_custom_password_column;
}
  • Related