diff --git a/models/Todo.js b/models/Todo.js index 7b92f3a..47b028d 100644 --- a/models/Todo.js +++ b/models/Todo.js @@ -8,6 +8,7 @@ const TodoSchema = Schema({ required: true, minLength: 1, maxLength: 300, + trim: true, }, list: { type: Schema.Types.ObjectId, ref: 'TodoList', required: true }, user: { type: Schema.Types.ObjectId, ref: 'User', required: true }, diff --git a/models/TodoList.js b/models/TodoList.js index fa551f6..f596a2a 100644 --- a/models/TodoList.js +++ b/models/TodoList.js @@ -8,6 +8,7 @@ const TodoListSchema = Schema({ required: true, minLength: 1, maxLength: 100, + trim: true, }, todos: [{ type: Schema.Types.ObjectId, ref: 'Todo' }], user: { type: Schema.Types.ObjectId, ref: 'User', required: true }, diff --git a/models/User.js b/models/User.js index 81b2c93..6f8ecfa 100644 --- a/models/User.js +++ b/models/User.js @@ -15,6 +15,7 @@ const UserSchema = Schema({ validate: /^\S*$/, minLength: 3, maxLength: 50, + trim: true, }, lists: [{ type: Schema.Types.ObjectId, ref: 'TodoList' }], todos: [{ type: Schema.Types.ObjectId, ref: 'Todo' }], @@ -35,7 +36,7 @@ UserSchema.pre('remove', async 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 () {