mirror of
https://github.com/usatiuk/ustk-todolist.git
synced 2025-10-28 23:57:49 +01:00
trim usernames, list names, todos,
change jwt expiration to in 120 days
This commit is contained in:
@@ -8,6 +8,7 @@ const TodoSchema = Schema({
|
|||||||
required: true,
|
required: true,
|
||||||
minLength: 1,
|
minLength: 1,
|
||||||
maxLength: 300,
|
maxLength: 300,
|
||||||
|
trim: true,
|
||||||
},
|
},
|
||||||
list: { type: Schema.Types.ObjectId, ref: 'TodoList', required: true },
|
list: { type: Schema.Types.ObjectId, ref: 'TodoList', required: true },
|
||||||
user: { type: Schema.Types.ObjectId, ref: 'User', required: true },
|
user: { type: Schema.Types.ObjectId, ref: 'User', required: true },
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ const TodoListSchema = Schema({
|
|||||||
required: true,
|
required: true,
|
||||||
minLength: 1,
|
minLength: 1,
|
||||||
maxLength: 100,
|
maxLength: 100,
|
||||||
|
trim: true,
|
||||||
},
|
},
|
||||||
todos: [{ type: Schema.Types.ObjectId, ref: 'Todo' }],
|
todos: [{ type: Schema.Types.ObjectId, ref: 'Todo' }],
|
||||||
user: { type: Schema.Types.ObjectId, ref: 'User', required: true },
|
user: { type: Schema.Types.ObjectId, ref: 'User', required: true },
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ const UserSchema = Schema({
|
|||||||
validate: /^\S*$/,
|
validate: /^\S*$/,
|
||||||
minLength: 3,
|
minLength: 3,
|
||||||
maxLength: 50,
|
maxLength: 50,
|
||||||
|
trim: true,
|
||||||
},
|
},
|
||||||
lists: [{ type: Schema.Types.ObjectId, ref: 'TodoList' }],
|
lists: [{ type: Schema.Types.ObjectId, ref: 'TodoList' }],
|
||||||
todos: [{ type: Schema.Types.ObjectId, ref: 'Todo' }],
|
todos: [{ type: Schema.Types.ObjectId, ref: 'Todo' }],
|
||||||
@@ -35,7 +36,7 @@ UserSchema.pre('remove', async function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
UserSchema.methods.generateJwt = function () {
|
UserSchema.methods.generateJwt = function () {
|
||||||
return jwt.sign({ id: this._id, username: this.username }, secret, { expiresIn: '6m' });
|
return jwt.sign({ id: this._id, username: this.username }, secret, { expiresIn: '120d' });
|
||||||
};
|
};
|
||||||
|
|
||||||
UserSchema.methods.toJson = function () {
|
UserSchema.methods.toJson = function () {
|
||||||
|
|||||||
Reference in New Issue
Block a user