Upgraded password hashing algo to argon2id.

This commit is contained in:
rainbow napkin 2025-10-18 09:42:08 -04:00
parent 895a8201a5
commit 5caa679b92
7 changed files with 56 additions and 33 deletions

View file

@ -164,7 +164,7 @@ userSchema.pre('save', async function (next){
//If the password was changed
if(this.isModified("pass")){
//Hash that sunnovabitch, no questions asked.
this.pass = hashUtil.hashPassword(this.pass);
this.pass = await hashUtil.hashPassword(this.pass);
}
//If the flair was changed
@ -321,7 +321,7 @@ userSchema.statics.authenticate = async function(user, pass, failLine = "Bad Use
}
//Check our password is correct
if(userDB.checkPass(pass)){
if(await userDB.checkPass(pass)){
return userDB;
}else{
//if not scream and shout
@ -492,8 +492,8 @@ userSchema.statics.processAgedIPRecords = async function(){
* @param {String} pass - Password to authenticate
* @returns {Boolean} True if authenticated
*/
userSchema.methods.checkPass = function(pass){
return hashUtil.comparePassword(pass, this.pass)
userSchema.methods.checkPass = async function(pass){
return await hashUtil.comparePassword(pass, this.pass)
}
/**
@ -824,7 +824,7 @@ userSchema.methods.killAllSessions = async function(reason = "A full log-out fro
* @param {Object} passChange - passChange object handed down from Browser
*/
userSchema.methods.changePassword = async function(passChange){
if(this.checkPass(passChange.oldPass)){
if(await this.checkPass(passChange.oldPass)){
if(passChange.newPass == passChange.confirmPass){
//Note: We don't have to worry about hashing here because the schema is written to do it auto-magically
this.pass = passChange.newPass;
@ -877,7 +877,7 @@ userSchema.methods.nuke = async function(pass){
}
//Check that the password is correct
if(this.checkPass(pass)){
if(await this.checkPass(pass)){
//delete the user
var oldUser = await this.deleteOne();
}else{