first commit
This commit is contained in:
43
models/User.js
Normal file
43
models/User.js
Normal file
@@ -0,0 +1,43 @@
|
||||
import mongoose from "mongoose";
|
||||
|
||||
const UserSchema = new mongoose.Schema(
|
||||
{
|
||||
username: String,
|
||||
steamId: String,
|
||||
avatar: String,
|
||||
tradeUrl: { type: String, default: null },
|
||||
account_creation: Number,
|
||||
communityvisibilitystate: Number,
|
||||
balance: { type: Number, default: 0 },
|
||||
intercom: { type: String, default: null },
|
||||
email: {
|
||||
address: { type: String, default: null },
|
||||
verified: { type: Boolean, default: false },
|
||||
emailToken: { type: String, default: null },
|
||||
},
|
||||
ban: {
|
||||
banned: { type: Boolean, default: false },
|
||||
reason: { type: String, default: null },
|
||||
expires: { type: Date, default: null },
|
||||
},
|
||||
staffLevel: { type: Number, default: 0 },
|
||||
twoFactor: {
|
||||
enabled: { type: Boolean, default: false },
|
||||
qrCode: { type: String, default: null },
|
||||
secret: { type: String, default: null },
|
||||
revocationCode: { type: String, default: null },
|
||||
},
|
||||
},
|
||||
{ timestamps: true }
|
||||
);
|
||||
|
||||
// Virtual property for admin check
|
||||
UserSchema.virtual("isAdmin").get(function () {
|
||||
return this.staffLevel >= 3; // Staff level 3 or higher is admin
|
||||
});
|
||||
|
||||
// Ensure virtuals are included in JSON
|
||||
UserSchema.set("toJSON", { virtuals: true });
|
||||
UserSchema.set("toObject", { virtuals: true });
|
||||
|
||||
export default mongoose.model("User", UserSchema);
|
||||
Reference in New Issue
Block a user