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?

Cris
  • 12,124
  • 27
  • 92
  • 159

1 Answers1

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
}
Antonio Carlos Ribeiro
  • 86,191
  • 22
  • 213
  • 204
  • 1
    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: http://stackoverflow.com/a/19880068/845680 – berrberr Jan 15 '14 at 16:20
  • I have one problem with this solution. {{ Auth::check() }} is returning false in my blade and true in the Controller.. – Vitali D. Aug 18 '17 at 16:31