Auth::attempt() is not working in Laravel 5.5

谁说胖子不能爱 提交于 2019-12-06 13:37:30

Even though you can implement a Service provider as describe in this post, You can do it manually by with using other auth method

This means you can do like so:

//....
try{
    $user = User::where('email', Input::get('email'))
      ->where('password', sha1(Input::get('password')))->firstOrFail();
    Auth::login($user);
} catch (ModelNotFoundException $e)
    return ['Username or password Incorrect'];
}

The best thing however is to use the bcrypt() in Laravel but the above should work in case bcrypt is no option.

Try this -

Route::post('login',function(){

$auth = Auth::attempt(['email'=>Input::get('email'),'password'=>Input::get('password')],$remember ? true : false);

dd($auth);
});

Hope this will work for you.

waterbrain

I solved it by converting the registering user password to sha1 and then to laravel hashing encryption like so Hash::make(sha1(Input::get('password')));

At login time I do like below

Hash::make(sha1(Input::get('password')))

Then $auth = Auth::attempt($creds); worked.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!