So I found a few problems already which says that you have to override getAuthPassword() to give custom name of password column from database. Tried putting this method with the same name as column in a database and didnt work. It still shoots this error: Undefined index: password.
This is the auth:
if (Auth::attempt(Input::only('user_displayName'), Input::get('user_password')))
Tried changing user_password to password both in form and controller nothing works.
So the question is if I have a column in a database called "user_password" is there a way to make Auth work?
P.S checked every older solution I found
EDIT
Structure of user table:
+======================+
| User |
+======================+
| user_id |
+----------------------+
| user_displayName |
+----------------------+
| user_fname |
+----------------------+
| user_lname |
+----------------------+
| user_email |
+----------------------+
| user_password |
+----------------------+
| created_at |
+----------------------+
| updated_at |
+----------------------+
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')))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With