Turn off auto delete and manual check ttl for token

This commit is contained in:
Maidul Islam
2023-02-11 11:08:46 -08:00
parent 8fd2578a6d
commit 2fb4b261a8
5 changed files with 29 additions and 16 deletions
+5 -5
View File
@@ -5,6 +5,7 @@ export interface IToken {
email: string;
token: string;
createdAt: Date;
ttl: Number;
}
const tokenSchema = new Schema<IToken>({
@@ -19,14 +20,13 @@ const tokenSchema = new Schema<IToken>({
createdAt: {
type: Date,
default: Date.now
},
ttl: {
type: Number,
}
});
tokenSchema.index({
createdAt: 1
}, {
expireAfterSeconds: parseInt(EMAIL_TOKEN_LIFETIME)
});
tokenSchema.index({ email: 1 });
const Token = model<IToken>('Token', tokenSchema);