|
@@ -853,13 +853,23 @@ module.exports = (crowi) => {
|
|
|
const { appService, mailService } = crowi;
|
|
const { appService, mailService } = crowi;
|
|
|
const { id } = req.body;
|
|
const { id } = req.body;
|
|
|
|
|
|
|
|
|
|
+ let newPassword;
|
|
|
|
|
+ let user;
|
|
|
|
|
+
|
|
|
try {
|
|
try {
|
|
|
- const [newPassword, user] = await Promise.all([
|
|
|
|
|
|
|
+ [newPassword, user] = await Promise.all([
|
|
|
await User.resetPasswordByRandomString(id),
|
|
await User.resetPasswordByRandomString(id),
|
|
|
await User.findById(id)]);
|
|
await User.findById(id)]);
|
|
|
|
|
|
|
|
activityEvent.emit('update', res.locals.activity._id, { action: SupportedAction.ACTION_ADMIN_USERS_PASSWORD_RESET });
|
|
activityEvent.emit('update', res.locals.activity._id, { action: SupportedAction.ACTION_ADMIN_USERS_PASSWORD_RESET });
|
|
|
|
|
+ }
|
|
|
|
|
+ catch (err) {
|
|
|
|
|
+ const msg = 'Error occurred during password reset request procedure.';
|
|
|
|
|
+ logger.error(err);
|
|
|
|
|
+ return res.apiv3Err(`${msg} Cause: ${err}`);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
+ try {
|
|
|
await mailService.send({
|
|
await mailService.send({
|
|
|
to: user.email,
|
|
to: user.email,
|
|
|
subject: 'Your password has been reset by the administrator',
|
|
subject: 'Your password has been reset by the administrator',
|
|
@@ -875,7 +885,7 @@ module.exports = (crowi) => {
|
|
|
return res.apiv3({});
|
|
return res.apiv3({});
|
|
|
}
|
|
}
|
|
|
catch (err) {
|
|
catch (err) {
|
|
|
- const msg = 'Error occurred during password reset request procedure.';
|
|
|
|
|
|
|
+ const msg = 'Error occurred during password reset send e-mail.';
|
|
|
logger.error(err);
|
|
logger.error(err);
|
|
|
return res.apiv3Err(`${msg} Cause: ${err}`);
|
|
return res.apiv3Err(`${msg} Cause: ${err}`);
|
|
|
}
|
|
}
|