mirror of
https://github.com/nodemailer/wildduck.git
synced 2025-03-15 17:46:04 +08:00
updates
This commit is contained in:
parent
4b3823e947
commit
dc6b6df8a6
2 changed files with 14 additions and 2 deletions
|
@ -1345,6 +1345,7 @@ module.exports = (db, server, userHandler) => {
|
||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
* @apiParam {String} id Users unique ID.
|
* @apiParam {String} id Users unique ID.
|
||||||
|
* @apiParam {String} [validAfter] Allow using the generated password not earlier than provided time
|
||||||
* @apiParam {String} [sess] Session identifier for the logs
|
* @apiParam {String} [sess] Session identifier for the logs
|
||||||
* @apiParam {String} [ip] IP address for the logs
|
* @apiParam {String} [ip] IP address for the logs
|
||||||
*
|
*
|
||||||
|
@ -1382,6 +1383,9 @@ module.exports = (db, server, userHandler) => {
|
||||||
.lowercase()
|
.lowercase()
|
||||||
.length(24)
|
.length(24)
|
||||||
.required(),
|
.required(),
|
||||||
|
validAfter: Joi.date()
|
||||||
|
.empty('')
|
||||||
|
.allow(false),
|
||||||
sess: Joi.string().max(255),
|
sess: Joi.string().max(255),
|
||||||
ip: Joi.string().ip({
|
ip: Joi.string().ip({
|
||||||
version: ['ipv4', 'ipv6'],
|
version: ['ipv4', 'ipv6'],
|
||||||
|
@ -1414,7 +1418,8 @@ module.exports = (db, server, userHandler) => {
|
||||||
}
|
}
|
||||||
res.json({
|
res.json({
|
||||||
success: true,
|
success: true,
|
||||||
password
|
password,
|
||||||
|
validAfter: result.value || new Date()
|
||||||
});
|
});
|
||||||
return next();
|
return next();
|
||||||
});
|
});
|
||||||
|
|
|
@ -357,6 +357,12 @@ class UserHandler {
|
||||||
return next(err);
|
return next(err);
|
||||||
}
|
}
|
||||||
if (success) {
|
if (success) {
|
||||||
|
if (userData.validAfter > new Date()) {
|
||||||
|
let err = new Error('Temporary password is not yet activated');
|
||||||
|
err.code = 'TempPasswordNotYetValid';
|
||||||
|
return next(err);
|
||||||
|
}
|
||||||
|
|
||||||
requirePasswordChange = true;
|
requirePasswordChange = true;
|
||||||
usingTemporaryPassword = true;
|
usingTemporaryPassword = true;
|
||||||
return next(null, true);
|
return next(null, true);
|
||||||
|
@ -371,7 +377,7 @@ class UserHandler {
|
||||||
// try master password
|
// try master password
|
||||||
checkMasterPassword((err, success) => {
|
checkMasterPassword((err, success) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
err.code = 'BcryptError';
|
err.code = err.code || 'BcryptError';
|
||||||
return callback(err);
|
return callback(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1167,6 +1173,7 @@ class UserHandler {
|
||||||
{
|
{
|
||||||
$set: {
|
$set: {
|
||||||
tempPassword: {
|
tempPassword: {
|
||||||
|
validAfter: data.validAfter || new Date(),
|
||||||
password: bcrypt.hashSync(password, consts.BCRYPT_ROUNDS),
|
password: bcrypt.hashSync(password, consts.BCRYPT_ROUNDS),
|
||||||
created: new Date()
|
created: new Date()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue