Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save CallumCarmicheal/c4b42d6d3b09c80305e2d9b5eccb3366 to your computer and use it in GitHub Desktop.
Save CallumCarmicheal/c4b42d6d3b09c80305e2d9b5eccb3366 to your computer and use it in GitHub Desktop.
The few line error that almost killed the business i work for
//
// What was in the source
//
// Old hashing method
if ($passwordType == 1)
if (!self::CheckPassword_Old($pass, $user))
return self::$E_LOGIN_STATUS_INVALID_PASSWORD_1;
// New hashing method
else if ($passwordType == 2)
if (!password_verify($pass, $user->getPassword()))
return self::$E_LOGIN_STATUS_INVALID_PASSWORD_2;
//
// What actually happened
//
// Old hashing method
if ($passwordType == 1) {
if (!self::CheckPassword_Old($pass, $user))
return self::$E_LOGIN_STATUS_INVALID_PASSWORD_1;
// New hashing method
else if ($passwordType == 2)
if (!password_verify($pass, $user->getPassword()))
return self::$E_LOGIN_STATUS_INVALID_PASSWORD_2;
}
// here is where we say the user logged in correctly,
// so if the user updated their password in the past 30+ days, they
// could be accessed by anyone :X
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment