i am using laravel manual authentication system.Submitting the form redirects to this route shown below.And in the authenticate () function the name and password never matches to which i stored earlier. i.e. Auth::attempt
is always false.
Route::post('/logintest', 'mycontroller@authenticate');
Route::get('/home', ['middleware' => 'auth', function() {
echo "home page";});
}]);
authenticate function:
public function authenticate(Request $request)
{
$input=$request->all();
$password=$input['password'];
$name=$input['name'];
if (Auth::attempt(['Name' => $name, 'Password' => $password]) ){
return redirect()->intended('/home');
} else
{
return redirect('/login')->with('message','Error logging in!');
}
}
I've registered the user this way. the password is hashed using bcrypt(). function. but in authenticate() function i am comparing with plain password. i somewhere read Auth
automatically handles it. OR Is there something should i change in config/auth.php because i've used name to authenticate instead of username?
public function register(Request $request)
{
$input=$request->all();
$password=bcrypt($input['password']);
$name=$input['name'];
$insert= User::insert(['Name'=>$name,'Password'=>$password]);
return redirect('/login')
->with('message','successfully Registered.');
}