Added logic to keep banned users out of site
This commit is contained in:
parent
c848994c1d
commit
26df91262f
4 changed files with 28 additions and 6 deletions
|
|
@ -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);
|
||||
Loading…
Add table
Add a link
Reference in a new issue