|
|
@@ -29,11 +29,11 @@ module.exports = (crowi) => {
|
|
|
],
|
|
|
};
|
|
|
|
|
|
- async function sendPasswordResetEmail(email, url, i18n) {
|
|
|
+ async function sendPasswordResetEmail(email, i18n, txtFile, url) {
|
|
|
return mailService.send({
|
|
|
to: email,
|
|
|
subject: 'Password Reset',
|
|
|
- template: path.join(crowi.localeDir, `${i18n}/notifications/passwordReset.txt`),
|
|
|
+ template: path.join(crowi.localeDir, `${i18n}/notifications/${txtFile}.txt`),
|
|
|
vars: {
|
|
|
appTitle: appService.getAppTitle(),
|
|
|
email,
|
|
|
@@ -59,7 +59,7 @@ module.exports = (crowi) => {
|
|
|
const passwordResetOrderData = await PasswordResetOrder.createPasswordResetOrder(email);
|
|
|
const url = new URL(`/forgot-password/${passwordResetOrderData.token}`, appUrl);
|
|
|
const oneTimeUrl = url.href;
|
|
|
- await sendPasswordResetEmail(email, oneTimeUrl, i18n);
|
|
|
+ await sendPasswordResetEmail(email, i18n, 'passwordReset', oneTimeUrl);
|
|
|
return res.apiv3();
|
|
|
}
|
|
|
catch (err) {
|
|
|
@@ -70,8 +70,10 @@ module.exports = (crowi) => {
|
|
|
});
|
|
|
|
|
|
router.put('/', csrf, validator.password, apiV3FormValidator, async(req, res) => {
|
|
|
- const { token, newPassword } = req.body;
|
|
|
+ const grobalLang = configManager.getConfig('crowi', 'app:globalLang');
|
|
|
+ const i18n = req.language || grobalLang;
|
|
|
|
|
|
+ const { token, newPassword } = req.body;
|
|
|
const passwordResetOrder = await PasswordResetOrder.findOne({ token });
|
|
|
const { email } = passwordResetOrder;
|
|
|
|
|
|
@@ -85,6 +87,7 @@ module.exports = (crowi) => {
|
|
|
try {
|
|
|
const userData = await user.updatePassword(newPassword);
|
|
|
const serializedUserData = serializeUserSecurely(userData);
|
|
|
+ await sendPasswordResetEmail(email, i18n, 'passwordResetSuccessful');
|
|
|
return res.apiv3({ userData: serializedUserData });
|
|
|
}
|
|
|
catch (err) {
|