0

Basically, I'm having a problem with laravels built in auth my problem is it only accepts if username is spelled "username" and password "password" but I am using a different spelling username = user_name, password = passwd

this is my code

Auth::attempt(array(
    'user_name' => $data['email'],
    'passwd' => $data['password']
));

if( Auth::check() )
{
    return Redirect::intended('/');
}

my column name is user_name, passwd

if I use the code above it does not work but if i rename my column to username and password and change my code to this below it works, but unfortunate I am not allowed to do so

Auth::attempt(array(
    'user_name' => $data['email'],
    'passwd' => $data['password']
));
eaponz
  • 574
  • 1
  • 16
  • 32
  • possible duplicate of [laravel 4 custom named password column](http://stackoverflow.com/questions/26002552/laravel-4-custom-named-password-column) – Jarek Tkaczyk Sep 26 '14 at 18:34
  • why don't you change the name of the columns in your table? – Flavio Sep 26 '14 at 18:56
  • check this http://www.mindworksdev.com/2013/06/laravel-4-different-usernamepasswd-fields-in/ – Flavio Sep 26 '14 at 22:18
  • as stated in my post, renaming my columns is not allowed – eaponz Sep 27 '14 at 03:31
  • @TheShiftExchange thank you for your comment, now I understand :) Is it possible to manually log the users but not using auth::attempt and store it in Auth session? – eaponz Sep 27 '14 at 08:05
  • @TheShiftExchange I think you are wrong. I've just created solution and it seems to work: http://stackoverflow.com/questions/26073309/how-to-change-custom-password-field-name-for-laravel-4-and-laravel-5-user-auth/ – Marcin Nabiałek Sep 27 '14 at 09:42
  • @MarcinNabiałek Why did you duplicate the question then post the answer there? You should post the answer here and delete your question – Laurence Sep 27 '14 at 09:47
  • @TheShiftExchange Because there are many questions about the same and I won't add the same answer in all questions. Moreover I hope that someone more experienced in Laravel will look at it because I'm not 100% sure it won't cause any other problems – Marcin Nabiałek Sep 27 '14 at 09:51
  • @MarcinNabiałek - your answer looks correct - so post it here and delete your question. Then when other people post the same 'question' that get closed as a duplicate to this question. That is how SO works. – Laurence Sep 27 '14 at 09:53
  • @TheShiftExchange OP haven't written anything about using `getAuthPassword` in question. I've mentioned about it in my question because I saw it in other places and people told it doesn't work for them – Marcin Nabiałek Sep 27 '14 at 10:00
  • @TheShiftExchange It's not that `password` field can't be changed. Only problem is `attempt` method, where you can't pass your password with different array index. Only this is hard-coded in the Eloquent provider, but db column may be named as you like. – Jarek Tkaczyk Sep 27 '14 at 12:17

0 Answers0