Different user name tables?

I have a form with two fields ( username, password ) and a mysql table with two identical fields (username, password) and I authentication system:

But I cannot make it work if my table fields have different names, for example: ( my_user, my_pass ).

If you just changed the username field to another, this also works for me, which creates problems, this is the password field.

My auth.php configuration

'driver' => 'eloquent' 

Update

An already found solution in my controller, the password name cannot be changed.

Before (WRONG): What I did in the first place was wrong.

 $userdata = array( 'my_user' => Input::get('my_user'), 'my_pass' => Input::get('my_pass') ); 

he should be

 $userdata = array( 'my_user' => Input::get('my_user'), 'password' => Input::get('my_pass') ); 
+6
source share
3 answers

You can define your own username and password in auth.php inside the configuration folder.

  return array( 'driver' => 'eloquent', 'username' => 'my_user', 'password' => 'my_pass', 'model' => 'User', 'table' => 'users', ); 

Hope this can help.

+7
source

I ran into this problem. You need to expand your model:

 // User.php use Illuminate\Auth\UserInterface; use Illuminate\Auth\Reminders\RemindableInterface; class User extends Eloquent implements UserInterface, RemindableInterface { protected $fillable = array('name','passwd','email','status','timezone','language','notify'); protected $hidden = array('passwd'); protected $table = "users_t"; protected $primaryKey = "uid"; public static $rules = array( 'name' => 'required', 'passwd' => 'required', 'email' => 'required' ); public function getAuthIdentifier() { return $this->getKey(); } public function getAuthPassword() { return $this->passwd; } public function getReminderEmail() { return $this->email; } public static function validate($data) { return Validator::make($data,static::$rules); } } 
+3
source

You also need to implement the following methods:

 public function getRememberToken(){ } public function setRememberToken($value){ } public function getRememberTokenName(){ } 
-4
source

Source: https://habr.com/ru/post/947782/


All Articles