BUGFIX: clear out old refresh tokens

This commit is contained in:
2022-12-01 12:06:20 +00:00
parent 763efb75bf
commit cec30620ec
2 changed files with 23 additions and 0 deletions
+11
View File
@@ -36,6 +36,17 @@ app.get('*', (req, res) => {
//startup
server.listen(process.env.WEB_PORT || 3200, async (err) => {
//BUGFIX: clear out old refresh tokens
const { Op } = require('sequelize');
const { tokens } = require('./database/models');
tokens.destroy({
where: {
createdAt: {
[Op.lt]: new Date(new Date().setDate(new Date().getDate() - 30))
}
}
});
await database.sync();
console.log(`listening to localhost:${process.env.WEB_PORT || 3200}`);
});