Updated ban UI to handle IP-Bans.
This commit is contained in:
parent
977e8e1e2e
commit
7624e1928a
8 changed files with 165 additions and 71 deletions
|
|
@ -306,24 +306,31 @@ userBanSchema.statics.unban = async function(user){
|
|||
}
|
||||
|
||||
userBanSchema.statics.getBans = async function(){
|
||||
const banDB = await this.find({}).populate('user');
|
||||
//Get the ban, populating users and alts
|
||||
const banDB = await this.find({}).populate('user').populate('alts');
|
||||
//Create an empty array to hold ban records
|
||||
var bans = [];
|
||||
|
||||
banDB.forEach((ban) => {
|
||||
//Calcualte expiration date
|
||||
//Create array to hold alts
|
||||
var alts = [];
|
||||
//Calculate expiration date
|
||||
var expirationDate = new Date(ban.banDate);
|
||||
expirationDate.setDate(expirationDate.getDate() + ban.expirationDays);
|
||||
|
||||
//Make sure we're not about to read the properties of a null object
|
||||
if(ban.user != null){
|
||||
var userObj = {
|
||||
id: ban.user.id,
|
||||
user: ban.user.user,
|
||||
img: ban.user.img,
|
||||
date: ban.user.date
|
||||
}
|
||||
var userObj = ban.user.getProfile();
|
||||
}
|
||||
|
||||
|
||||
//For each alt in the ban
|
||||
for(alt of ban.alts){
|
||||
//Get the profile and push it to the alt list
|
||||
alts.push(alt.getProfile());
|
||||
}
|
||||
|
||||
//Create ban object
|
||||
const banObj = {
|
||||
banDate: ban.banDate,
|
||||
expirationDays: ban.expirationDays,
|
||||
|
|
@ -331,14 +338,16 @@ userBanSchema.statics.getBans = async function(){
|
|||
daysUntilExpiration: ban.getDaysUntilExpiration(),
|
||||
user: userObj,
|
||||
ips: ban.ips,
|
||||
alts: ban.alts,
|
||||
alts,
|
||||
deletedNames: ban.deletedNames,
|
||||
permanent: ban.permanent
|
||||
}
|
||||
|
||||
//Add it to the array
|
||||
bans.push(banObj);
|
||||
});
|
||||
|
||||
//Return the array
|
||||
return bans;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -74,22 +74,23 @@ const userSchema = new mongoose.Schema({
|
|||
required: true,
|
||||
default: "/img/johnny.png"
|
||||
},
|
||||
//These should be larger than validator values to make room for escaped characters
|
||||
bio: {
|
||||
type: mongoose.SchemaTypes.String,
|
||||
required: true,
|
||||
maxLength: 1000,
|
||||
maxLength: 2000,
|
||||
default: "Bio not set!"
|
||||
},
|
||||
pronouns:{
|
||||
type: mongoose.SchemaTypes.String,
|
||||
optional: true,
|
||||
maxLength: 20,
|
||||
maxLength: 50,
|
||||
default: ""
|
||||
},
|
||||
signature: {
|
||||
type: mongoose.SchemaTypes.String,
|
||||
required: true,
|
||||
maxLength: 150,
|
||||
maxLength: 300,
|
||||
default: "Signature not set!"
|
||||
},
|
||||
highLevel: {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue