Password reset tokens now auto-expire when new reset requests are made.
This commit is contained in:
parent
edbc9909a1
commit
cb5f1dbf9b
|
|
@ -72,6 +72,12 @@ passwordResetSchema.pre('save', async function (next){
|
||||||
this.ipHash = hashUtil.hashIP(this.ipHash);
|
this.ipHash = hashUtil.hashIP(this.ipHash);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//If the user was modified (usually only on document initialization)
|
||||||
|
if(this.isModified('user')){
|
||||||
|
//Delete previous requests for the given user
|
||||||
|
const requests = await this.model().deleteMany({user: this.user._id});
|
||||||
|
}
|
||||||
|
|
||||||
next();
|
next();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue