trim usernames, list names, todos,

change jwt expiration to in 120 days
This commit is contained in:
2018-06-01 21:03:15 +03:00
parent ca6281e2a6
commit 5747b9ade3
3 changed files with 4 additions and 1 deletions

View File

@@ -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 () {