|
|
@@ -1,3 +1,4 @@
|
|
|
+import { format } from 'date-fns';
|
|
|
import rateLimit from 'express-rate-limit';
|
|
|
|
|
|
import PasswordResetOrder from '~/server/models/password-reset-order';
|
|
|
@@ -45,23 +46,23 @@ module.exports = (crowi) => {
|
|
|
|
|
|
const checkPassportStrategyMiddleware = checkForgotPasswordEnabledMiddlewareFactory(crowi, true);
|
|
|
|
|
|
- async function sendPasswordResetEmail(txtFileName, i18n, email, url) {
|
|
|
+ async function sendPasswordResetEmail(txtFileName, i18n, email, url, expiredAt) {
|
|
|
return mailService.send({
|
|
|
to: email,
|
|
|
- subject: txtFileName,
|
|
|
+ subject: '[GROWI] Password Reset',
|
|
|
template: path.join(crowi.localeDir, `${i18n}/notifications/${txtFileName}.txt`),
|
|
|
vars: {
|
|
|
appTitle: appService.getAppTitle(),
|
|
|
email,
|
|
|
url,
|
|
|
+ expiredAt,
|
|
|
},
|
|
|
});
|
|
|
}
|
|
|
|
|
|
router.post('/', checkPassportStrategyMiddleware, async(req, res) => {
|
|
|
const { email } = req.body;
|
|
|
- const grobalLang = configManager.getConfig('crowi', 'app:globalLang');
|
|
|
- const i18n = req.language || grobalLang;
|
|
|
+ const i18n = configManager.getConfig('crowi', 'app:globalLang');
|
|
|
const appUrl = appService.getSiteUrl();
|
|
|
|
|
|
try {
|
|
|
@@ -76,7 +77,8 @@ module.exports = (crowi) => {
|
|
|
const passwordResetOrderData = await PasswordResetOrder.createPasswordResetOrder(email);
|
|
|
const url = new URL(`/forgot-password/${passwordResetOrderData.token}`, appUrl);
|
|
|
const oneTimeUrl = url.href;
|
|
|
- await sendPasswordResetEmail('passwordReset', i18n, email, oneTimeUrl);
|
|
|
+ const expiredAt = format(passwordResetOrderData.expiredAt, 'yyyy/MM/dd HH:mm');
|
|
|
+ await sendPasswordResetEmail('passwordReset', i18n, email, oneTimeUrl, expiredAt);
|
|
|
return res.apiv3();
|
|
|
}
|
|
|
catch (err) {
|