UNPKG

@materia/users

Version:

Signin/signup your users in your Materia application

34 lines (28 loc) 525 B
const Sequelize = require('sequelize'); class UserTokenModel { constructor(app, entity) { this.app = app; this.model = entity.model; } clearExpiredTokens() { return this.model.destroy({ where: { expires_in: { [Sequelize.Op.lt]: new Date() } } }) } getActiveTokens(params) { return this.model.findAll({ where: { expires_in: { [Sequelize.Op.gt]: new Date() }, id_user: params.id_user }, order: [['expires_in', 'DESC']] }) } } module.exports = UserTokenModel;