Skip to content

Commit

Permalink
add delay before remove token
Browse files Browse the repository at this point in the history
  • Loading branch information
fxmontigny committed Aug 8, 2023
1 parent 28e1ddc commit e0081bc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion api/config/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ module.exports = {
/**
* Token expiration delay
*/
nbMaxDayTokenLife: 30,
nbMaxDayTokenLife: 7,
/**
* Force HTTP to HTTPS
*/
Expand Down
3 changes: 2 additions & 1 deletion api/src/models/TableTokens.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@ export default (sequelizeInstance, Model) => {

if (ref) {
const date = new Date()
const tokenCreateAt = new Date(ref.dataValues.created_at)
const tokenCreateAt = new Date(ref.dataValues.updated_at)
const nbDays = getNbDay(tokenCreateAt, date)

if (nbDays <= config.nbMaxDayTokenLife) {
ref.update({ updated_at: new Date() })
return ref
} else {
await Model.deleteToken(token)
Expand Down

0 comments on commit e0081bc

Please sign in to comment.