Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Daniel1836's avatar

These credentials do not match our records. (Log in) (Laravel)

Hi,

I am building the Forum app listed in the Laracasts Series (Laravel) on this site.

I can register fine, but the login section I get the error (These credentials do not match our records.) even though the (email etc) information is inside my users table in the database.

The files I am using are the standard boiler plate I get from using the (php artisan make:auth) command.

Does anyone know a solution?

I suspect from my research the password is suspect. (it is being hashed).

Thanks

0 likes
25 replies
jlrdw's avatar

What version of laravel. And the login page load just fine.

Also use the browser developer tools to help troubleshoot the issue.

1 like
Daniel1836's avatar

version 5.2.45

Technically registering automatically logs you in. But I want to be able to log in using credentials after logging out.

2 likes
jlrdw's avatar

If you log out, can you log back in. Or is there errors.

1 like
Daniel1836's avatar

No. Then it says (These credentials do not match our records.) in red. It asks for the email and the password.

1 like
asadsajjad's avatar

try echoing the username and password and see if its getting both inputs or not

Do below in your controller and see if its getting username and password same as your database (if you are using hashing then comment that part to check the password match)

echo $username; echo $password; die;

jlrdw's avatar

Is the email and password being stored in the database. Is the password properly being bcrypted.

1 like
Daniel1836's avatar

They are both being stored in the database. The email appears correct, the password is being hashed in the database so I can't verify that they are a match.

From what I found on google one person recommended (bcrypt password) Checking all the relevant php files I don't think so, it is being hashed.

Daniel1836's avatar

I'm not 100% sure this the correct code snippet. It is from (RegisterController.php)

protected function create(array $data) { return User::create([ 'name' => $data['name'], 'email' => $data['email'], 'password' => Hash::make($data['password']), ]); }

asadsajjad's avatar

try this

protected function create(array $data) { 
return User::create([ 
	'name' => $data['name'], 
	'email' => $data['email'], 
	'password' => bcrypt($data['password']),
]); 
}
1 like
Daniel1836's avatar

Not working yet.

I have also tried pulling in different stuff in various files, like (use App\Models\User;)

jlrdw's avatar

Something is wrong with your setup, the out of the box Authentication should work without modifying stuff.

asadsajjad's avatar

@daniel1836 try doing it manual way then. Try this

use Input;
use App\User;

class RegisterController extends Controller
{
	public function create() {
		$username = Input::get('name');
		$email= Input::get('email');
		$password= Input::get('password');

		$encrypted_password = bcrypt($password);

		$users = new User();
		$users->username = $username;
		$users->email = $email;
		$users->password = $encrypted_password;

		$users->save()
	}
	
}
Snapey's avatar

The most likely problem is a mismatch in the number of times the password is hashed.

Its either twice when registering (thus destroying the password), or

its hashed twice when logging in so does not match the database.

This can be caused by one of the following being the case;

  • The User model has an accessor that automatically hashes the password, but you are doing it outside of the model also
  • The User model has an observer on creating that automatically hashes the password, but you are doing it outside of the model also
  • Your login script is hashing the password then passing it to the check function (when it is not required to hash first)

None of the above should be a problem when using out of the box authentication - it just works.

So, it must be something you have changed.

But first things first, you should check that your credentials are correctly being passed to the login controller.

8 likes
JPFarber's avatar

@Snapey With your explanaition, I saw that I must delete a redundant code from my User Model [method: public function setPasswordAttribute($value)].

Thanks

amitsolanki24_'s avatar

@techbros You have to delete your hash password code that si duplicate like if you have set password hahsed in casts then no need to manually Hash::make($password)

If its still not jot work than please share your code.

techbros's avatar

@amitsolanki24_ please how can I delete the hash password code I saw the Hash::make($password) what should I change it too

techbros's avatar

@amitsolanki24_ this what my codes looks like on the register controller php file protected function create(array $data) { $general = gs();

    $referBy = session()->get('reference');
    if ($referBy) {
        $referUser = User::where('username', $referBy)->first();
    } else {
        $referUser = null;
    }
    //User Create
    $user               = new User();
    $user->email        = strtolower(trim($data['email']));
    $user->password     = Hash::make($data['password']);
    $user->username     = trim($data['username']);
    $user->ref_by       = $referUser ? $referUser->id : 0;
    $user->country_code = $data['country_code'];
    $user->mobile       = $data['mobile_code'] . $data['mobile'];
    $user->address      = [
        'address' => '',
        'state' => '',
        'zip' => '',
        'country' => isset($data['country']) ? $data['country'] : null,
        'city' => ''
    ];
    $user->status = Status::USER_ACTIVE;
    $user->kv = $general->kv ? Status::UNVERIFIED : Status::VERIFIED;
    $user->ev = $general->ev ? Status::UNVERIFIED : Status::VERIFIED;
    $user->sv = $general->sv ? Status::UNVERIFIED : Status::VERIFIED;
    $user->ts = Status::ENABLE;
    $user->tv = Status::VERIFIED;
    $user->save();
1 like
JPFarber's avatar

@techbros You need to check if you are not hashing the password twice or more. If you hash your password into a Controller@store, then In your User Model you should not have some function where the password will be hashed again.

1 like

Please or to participate in this conversation.