2024-10-29 21:09:13 +01:00
|
|
|
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
|
2024-11-18 17:37:57 +01:00
|
|
|
},
|
|
|
|
failedLoginAttempts: { // Track failed login attempts
|
|
|
|
type: Number,
|
|
|
|
default: 0
|
|
|
|
},
|
|
|
|
lastFailedLogin: { // Track the last failed login attempt time
|
|
|
|
type: Date,
|
|
|
|
default: null
|
|
|
|
},
|
2024-10-29 21:09:13 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
module.exports = mongoose.model('User', userSchema);
|