|
|
@@ -18,6 +18,25 @@ const logger = loggerFactory('growi:routes:apiv3:forgotPassword'); // eslint-dis
|
|
|
const express = require('express');
|
|
|
const { body } = require('express-validator');
|
|
|
|
|
|
+/**
|
|
|
+ * @swagger
|
|
|
+ *
|
|
|
+ * components:
|
|
|
+ * schemas:
|
|
|
+ * PasswordResetRequest:
|
|
|
+ * type: object
|
|
|
+ * properties:
|
|
|
+ * email:
|
|
|
+ * type: string
|
|
|
+ * format: email
|
|
|
+ * PasswordResetResponse:
|
|
|
+ * type: object
|
|
|
+ * properties:
|
|
|
+ * message:
|
|
|
+ * type: string
|
|
|
+ * error:
|
|
|
+ * type: string
|
|
|
+*/
|
|
|
|
|
|
const router = express.Router();
|
|
|
|
|
|
@@ -69,6 +88,34 @@ module.exports = (crowi) => {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @swagger
|
|
|
+ *
|
|
|
+ * /forgot-password:
|
|
|
+ * post:
|
|
|
+ * summary: Request password reset
|
|
|
+ * tags: [Users]
|
|
|
+ * security:
|
|
|
+ * -
|
|
|
+ * requestBody:
|
|
|
+ * required: true
|
|
|
+ * content:
|
|
|
+ * application/json:
|
|
|
+ * schema:
|
|
|
+ * type: object
|
|
|
+ * properties:
|
|
|
+ * email:
|
|
|
+ * type: string
|
|
|
+ * format: email
|
|
|
+ * description: Email address of the user requesting password reset
|
|
|
+ * responses:
|
|
|
+ * '200':
|
|
|
+ * description: Password reset request processed
|
|
|
+ * content:
|
|
|
+ * application/json:
|
|
|
+ * schema:
|
|
|
+ * type: object
|
|
|
+ */
|
|
|
router.post('/', checkPassportStrategyMiddleware, validator.email, apiV3FormValidator, addActivity, async(req, res) => {
|
|
|
const { email } = req.body;
|
|
|
const locale = configManager.getConfig('crowi', 'app:globalLang');
|
|
|
@@ -103,6 +150,37 @@ module.exports = (crowi) => {
|
|
|
}
|
|
|
});
|
|
|
|
|
|
+ /**
|
|
|
+ * @swagger
|
|
|
+ *
|
|
|
+ * /forgot-password:
|
|
|
+ * put:
|
|
|
+ * summary: Reset password
|
|
|
+ * tags: [Users]
|
|
|
+ * security:
|
|
|
+ * -
|
|
|
+ * requestBody:
|
|
|
+ * required: true
|
|
|
+ * content:
|
|
|
+ * application/json:
|
|
|
+ * schema:
|
|
|
+ * type: object
|
|
|
+ * properties:
|
|
|
+ * newPassword:
|
|
|
+ * type: string
|
|
|
+ * format: password
|
|
|
+ * description: New password
|
|
|
+ * responses:
|
|
|
+ * '200':
|
|
|
+ * description: Password reset successful
|
|
|
+ * content:
|
|
|
+ * application/json:
|
|
|
+ * schema:
|
|
|
+ * type: object
|
|
|
+ * properties:
|
|
|
+ * userData:
|
|
|
+ * $ref: '#/components/schemas/User'
|
|
|
+ */
|
|
|
// eslint-disable-next-line max-len
|
|
|
router.put('/', checkPassportStrategyMiddleware, injectResetOrderByTokenMiddleware, validator.password, apiV3FormValidator, addActivity, async(req, res) => {
|
|
|
const { passwordResetOrder } = req;
|