diff --git a/bin/database/models.js b/bin/database/models.js index 0145af2..da4e5d8 100644 --- a/bin/database/models.js +++ b/bin/database/models.js @@ -86,7 +86,7 @@ models.authCode = new Schema({ applicationId: Schema.Types.ObjectId, // reference to application userId: Schema.Types.ObjectId, // reference to user token: String, // generated token, only usable in combination with userId and applicationId - timestamp: { type: Date, default: Date.now } + timestamp: { type: Date, default: Date.now, index: {unique: true, expires: '5m'} } }); module.exports = (con) => { diff --git a/bin/database/module.js b/bin/database/module.js index 2ac7c75..505e6c1 100644 --- a/bin/database/module.js +++ b/bin/database/module.js @@ -33,7 +33,8 @@ methods.connect = async () => { mongoose.connect(cfg.mongoose.uri, { useNewUrlParser: true, useUnifiedTopology: true, - useFindAndModify: false + useFindAndModify: false, + useCreateIndex: true });