laravel 4 custom named password column

tldr; You can name your password field anything you like, as long as your User model implements the interface correctly.

However you can’t pass different array key to the Auth::attempt method – only password index can be there

First off you’re doing it wrong – you need to pass an array of credentials as 1st param:

if (Auth::attempt(Input::only('user_displayName', 'user_password')))

Next, unfortunately Eloquent provider has hard-coded password array index in the code, so you can’t pass user_password to the attempt method.

So this is what you need:

$credentials = Input::only('user_displayName');
$credentials['password'] = Input::get('user_password');

if (Auth::attempt($credentials))

// or simply rename the input in your form to password and:
if (Auth::attempt(Input::only('user_displayName', 'password')))

Leave a Comment