v1.18.x
Barış Soner Uşaklı 4 years ago
parent 177a961000
commit db63f5e3f0

@ -1,20 +1,20 @@
'use strict'; 'use strict';
var nconf = require('nconf'); const nconf = require('nconf');
var winston = require('winston'); const winston = require('winston');
var user = require('./index'); const user = require('./index');
const groups = require('../groups'); const groups = require('../groups');
var utils = require('../utils'); const utils = require('../utils');
var batch = require('../batch'); const batch = require('../batch');
var db = require('../database'); const db = require('../database');
var meta = require('../meta'); const meta = require('../meta');
var emailer = require('../emailer'); const emailer = require('../emailer');
var UserReset = module.exports; const UserReset = module.exports;
var twoHours = 7200000; const twoHours = 7200000;
UserReset.validate = async function (code) { UserReset.validate = async function (code) {
const uid = await db.getObjectField('reset:uid', code); const uid = await db.getObjectField('reset:uid', code);
@ -85,11 +85,13 @@ UserReset.commit = async function (code, password) {
}; };
UserReset.updateExpiry = async function (uid) { UserReset.updateExpiry = async function (uid) {
const oneDay = 1000 * 60 * 60 * 24;
const expireDays = meta.config.passwordExpiryDays; const expireDays = meta.config.passwordExpiryDays;
const expiry = Date.now() + (oneDay * expireDays);
if (expireDays > 0) { if (expireDays > 0) {
const oneDay = 1000 * 60 * 60 * 24;
const expiry = Date.now() + (oneDay * expireDays);
await user.setUserField(uid, 'passwordExpiry', expiry); await user.setUserField(uid, 'passwordExpiry', expiry);
} else {
await db.deleteObjectField('user:' + uid, 'passwordExpiry');
} }
}; };

Loading…
Cancel
Save