kaori 4 лет назад
Родитель
Сommit
fbb711d0b2

+ 1 - 1
src/client/js/components/PasswordResetExecutionForm.jsx

@@ -33,7 +33,7 @@ const PasswordResetExecutionForm = (props) => {
       */
 
       await appContainer.apiPut('/forgot-password', {
-        newPassword, newPasswordConfirm,
+        newPassword,
       });
 
       setNewPassword('');

+ 1 - 1
src/server/middlewares/password-reset.js

@@ -10,7 +10,7 @@ module.exports = (crowi, app) => {
 
     const passwordResetOrder = await PasswordResetOrder.findOne({ token });
     // check the oneTimeToken is valid
-    if (passwordResetOrder == null || passwordResetOrder.isExpired()) {
+    if (passwordResetOrder == null /* || passwordResetOrder.isExpired() */) {
       return res.redirect('/forgot-password/error/password-reset-order');
     }
 

+ 11 - 11
src/server/routes/forgot-password.js

@@ -3,6 +3,7 @@ const ApiResponse = require('../util/apiResponse');
 
 module.exports = function(crowi, app) {
   const PasswordResetOrder = crowi.model('PasswordResetOrder');
+  const User = crowi.model('User');
   const { appService, mailService, configManager } = crowi;
   const path = require('path');
   const actions = {};
@@ -62,23 +63,22 @@ module.exports = function(crowi, app) {
 
 
   api.put = async(req, res) => {
-    console.log('hoooge');
-    // const { body, user } = req;
-    // const { oldPassword, newPassword } = body;
+    const { newPassword, email } = req.body;
 
     //  findOne User
+    const user = User.findOne({ email });
 
     // if (user.isPasswordSet() && !user.isPasswordValid(oldPassword)) {
     //   return res.apiv3Err('wrong-current-password', 400);
     // }
-    // try {
-    //   const userData = await user.updatePassword(newPassword);
-    //   return res.apiv3({ userData });
-    // }
-    // catch (err) {
-    //   logger.error(err);
-    //   return res.apiv3Err('update-password-failed');
-    // }
+    try {
+      const userData = await user.updatePassword(newPassword);
+      return res.apiv3({ userData });
+    }
+    catch (err) {
+      logger.error(err);
+      return res.json(ApiResponse.error('update-password-failed'));
+    }
   };