webinterface/server/models/User.js

39 lines
849 B
JavaScript

const mongoose = require('mongoose');
const userSchema = new mongoose.Schema({
username: {
type: String,
required: true,
unique: true,
trim: true
},
email: {
type: String,
required: true,
unique: true,
trim: true
},
password: {
type: String, // Wird davor zu einem Hash umgewandelt
required: true
},
createdAt: {
type: Date,
default: Date.now
},
isAdmin: {
type: Boolean,
default: false // Standardwert ist false
},
failedLoginAttempts: { // Track failed login attempts
type: Number,
default: 0
},
lastFailedLogin: { // Track the last failed login attempt time
type: Date,
default: null
},
});
module.exports = mongoose.model('User', userSchema);