Added logic to keep banned users out of site

This commit is contained in:
rainbow napkin 2024-11-29 09:00:47 -05:00
parent c848994c1d
commit 26df91262f
4 changed files with 28 additions and 6 deletions

View file

@ -159,4 +159,14 @@ userBanSchema.statics.getBans = async function(){
return bans;
}
//methods
userBanSchema.methods.getDaysUntilExpiration = function(){
//Get ban date
const expirationDate = new Date(this.banDate);
//Get expiration days and calculate expiration date
expirationDate.setDate(expirationDate.getDate() + this.expirationDays);
//Calculate and return days until ban expiration
return ((expirationDate - new Date()) / (1000 * 60 * 60 * 24)).toFixed(1);
}
module.exports = mongoose.model("userBan", userBanSchema);