0

I'm migrating a Drupal6 project in Laravel, so i need to use the "old" Drupal6 users table with passwords in MD5. Is there a way to modify the call to Auth passing the password in md5, without modifying the core Laravel files?

I do:

$userdata = array(
   'mail'   => Input::get('email'),
'password'  => Input::get('password')
);
if (Auth::attempt($userdata)) {
    //OK
}
else {
   //KO
}

How can i handle custom user auth in Laravel?

1 Answer 1

3

No, but you can do the auth yourself easily:

$user = User::where('email', Input::get('email'))->first();

if( $user && $user->password == md5(Input::get('password')) )
{
    Auth::login($user); /// will log the user in for you

    return Redirect::intended('dashboard');
}
else
{
   /// User not found or wrong password
}
Sign up to request clarification or add additional context in comments.

2 Comments

Also, you should not be using MD5. It is simply not a secure way to store passwords anymore. Consider converting the old MD5 hashes to the format Laravel uses (Bcrypt). This answer does exactly what you need, and is very simple to implement: stackoverflow.com/a/19880068/845680
I have one problem with this solution. {{ Auth::check() }} is returning false in my blade and true in the Controller..

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.