Support the ongoing development of Laravel.io →
Authentication
Last updated 2 years ago.
0

I don't think you need to hash the password before using Auth::attempt()

Last updated 2 years ago.
0

thepsion5 said:

I don't think you need to hash the password before using Auth::attempt()

Thanks for the reply Sir. I tried also to remove it by using this code

  $credentials = [
        'email' => Input::get('email'),
        'password' => Input::get('password')
 ];

if(Auth::attempt($credentials)) {
			 return 'success';
}else {
			 return 'auth failed';
}	

but it doesn't fixed the error.

Last updated 2 years ago.
0

Make sure that your password column on your users table is long enough, it's possible the passwords are getting cut off. See this topic: http://laravel.io/forum/04-17-2014-hashcheck-nor-hashattempt-match-with-original-password

After making your column long enough you'll need to re-register your users (or manually update their password hash).

Last updated 2 years ago.
0

My password has a limit of 255 characters, yes I tried to delete and re-register my user but the error is still there.

Last updated 2 years ago.
0

I had the same problem, but i couldn't find a solution, instead i ran the query to check for credentials, and then i forced login.

		$auth = User::where('Username', '=', Input::get('username'))->where('Password', '=', Hash::make(Input::get('password')))->first();
		if($auth){
			Auth::login($auth);
			}
			return Redirect::intended('home');
		}
Last updated 2 years ago.
0

Joe96 said:

I had the same problem, but i couldn't find a solution, instead i ran the query to check for credentials, and then i forced login.

  	$auth = User::where('Username', '=', Input::get('username'))->where('Password', '=', Hash::make(Input::get('password')))->first();
  	if($auth){
  		Auth::login($auth);
  		}
  		return Redirect::intended('home');
  	}

Thanks for the tips but when I tried to use your code

$auth = User::where('email', '=', Input::get('email'))->where('Password', '=', Hash::make(Input::get('password')))->first();
        if($auth){
            Auth::login($auth);
            
            return Redirect::intended('submit');
		}else {
			 return 'auth failed';
		}	

still I am receiving auth failed

Last updated 2 years ago.
0

Nevermind, I see the problem, the problem is with your registration. You're not storing the password in a hashed form, you're hashing the password to validate it (it should be validated in its original form) and then hashed for storage.

$data = array(
	'email'           => Input::get('email'),
	'firstname'       => Input::get('firstname'),
	'lastname'        => Input::get('lastname'),
	'password'        => Hash::make($password)
);        

Should be:

$data = array(
	'email'           => Input::get('email'),
	'firstname'       => Input::get('firstname'),
	'lastname'        => Input::get('lastname'),
	'password'        => Input::get('password')
);        

And this:

$user = new User;
$user->firstname       = Input::get('firstname');
$user->lastname        = Input::get('lastname');
$user->email           = Input::get('email');
$user->password        = Input::get('password');
$user->save();

Should be:

$user = new User;
$user->firstname       = Input::get('firstname');
$user->lastname        = Input::get('lastname');
$user->email           = Input::get('email');
$user->password        = Hash::make(Input::get('password'));
$user->save();
Last updated 2 years ago.
0

citricsquid said:

helmikuu27 said: still I am receiving auth failed

Are you absolutely sure that the password is correct? Do the following:

echo Hash::make('password-here');

Then compare the result against the hash stored in your database, see if they match.

Thank you very much! This suggestion gave me an idea how to use the Hash::make function. The error is fixed by hashing the password before storing it into database and do the basic validation on my controller. I learn a lot today. Thanks again. :)

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

helmikuu27 helmikuu27 Joined 31 Mar 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.