فهرست منبع

170342-178601 correct forgot-password.js

mariko-h 2 هفته پیش
والد
کامیت
bb41e0ac4d
1فایلهای تغییر یافته به همراه4 افزوده شده و 0 حذف شده
  1. 4 0
      apps/app/src/server/routes/apiv3/forgot-password.js

+ 4 - 0
apps/app/src/server/routes/apiv3/forgot-password.js

@@ -84,6 +84,7 @@ module.exports = (crowi) => {
 
   const checkPassportStrategyMiddleware =
     checkForgotPasswordEnabledMiddlewareFactory(crowi, true);
+  const ALLOWED_TEMPLATE_NAMES = ['passwordReset', 'passwordResetSuccessful'];
 
   async function sendPasswordResetEmail(
     templateFileName,
@@ -92,6 +93,9 @@ module.exports = (crowi) => {
     url,
     expiredAt,
   ) {
+    if (!ALLOWED_TEMPLATE_NAMES.includes(templateFileName)) {
+      throw new Error(`Invalid template name: ${templateFileName}`);
+    }
     const templatePath = resolveLocalePath(
       locale,
       crowi.localeDir,