Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix the bug in the login procedure:
Every time users log in, the password changes automatically, causing the user to not be able to log in 2nd time.
In the original code, this is what happens:
When user logs in, the
updatePwdHashIfNeeded
function inLoginFormsProcess
is called.That function then calls
pwdNeedsRehash
function to check if the password needs rehash, and if so, receivesnew password hash.
That password hash then is sent to
changePassword
function as an argument in theUserCoreModel
.The
changePassword
function then takes the password hash as an argument instead of the password itself and runs this code:$rStmt->bindValue(':newPassword', Security::hashPwd($sNewPassword), PDO::PARAM_STR);
, which decrypts the already password hash instead of decrypting the password itself.There is nothing wrong with
changePassword
. But thechangePassword
shouldn't get password hash, but the password itself is an argument. Which in current code wasn't the case, which caused the password to be changed without any intention. So, I made some changes to fix this bug.To fix this, I changed the following:
pwdNeedsRehash
function on Security.class.php changed: instead of returning the password hash, it just returns TRUE or FALSE.updatePwdHashIfNeeded
function on LoginFormProcess changed: instead of sending the password hash as arugment, it sends the password itself as argument to thechangePassword
function. I changed the "if" statement as there is no need to save TRUE or FALSE value returned from pwdNeedsRehash function on Security.class.php.I controlled where the
pwdNeedsRehash
function is used, and my changes don't break any other parts of the project.