|
|
@@ -45,6 +45,22 @@ const ErrorV3 = require('../../models/vo/error-apiv3');
|
|
|
* type: string
|
|
|
* newPasswordConfirm:
|
|
|
* type: string
|
|
|
+ * AssociateUser:
|
|
|
+ * description: Ldap account for associate
|
|
|
+ * type: object
|
|
|
+ * properties:
|
|
|
+ * username:
|
|
|
+ * type: string
|
|
|
+ * password:
|
|
|
+ * type: string
|
|
|
+ * DisassociateUser:
|
|
|
+ * description: Ldap account for disassociate
|
|
|
+ * type: object
|
|
|
+ * properties:
|
|
|
+ * providerType:
|
|
|
+ * type: string
|
|
|
+ * accountId:
|
|
|
+ * type: string
|
|
|
*/
|
|
|
module.exports = (crowi) => {
|
|
|
const accessTokenParser = require('../../middleware/access-token-parser')(crowi);
|
|
|
@@ -302,7 +318,32 @@ module.exports = (crowi) => {
|
|
|
|
|
|
});
|
|
|
|
|
|
- // TODO swagger
|
|
|
+ /**
|
|
|
+ * @swagger
|
|
|
+ *
|
|
|
+ * /personal-setting/associate-ldap:
|
|
|
+ * put:
|
|
|
+ * tags: [PersonalSetting]
|
|
|
+ * operationId: associateLdapAccount
|
|
|
+ * summary: /personal-setting/associate-ldap
|
|
|
+ * description: associate Ldap account
|
|
|
+ * requestBody:
|
|
|
+ * required: true
|
|
|
+ * content:
|
|
|
+ * application/json:
|
|
|
+ * schema:
|
|
|
+ * $ref: '#/components/schemas/AssociateUser'
|
|
|
+ * responses:
|
|
|
+ * 200:
|
|
|
+ * description: succeded to associate Ldap account
|
|
|
+ * content:
|
|
|
+ * application/json:
|
|
|
+ * schema:
|
|
|
+ * properties:
|
|
|
+ * associateUser:
|
|
|
+ * type: object
|
|
|
+ * description: Ldap account associate to me
|
|
|
+ */
|
|
|
router.put('/associate-ldap', accessTokenParser, loginRequiredStrictly, csrf, validator.associateLdap, ApiV3FormValidator, async(req, res) => {
|
|
|
const { passportService } = crowi;
|
|
|
const { user, body } = req;
|
|
|
@@ -325,7 +366,32 @@ module.exports = (crowi) => {
|
|
|
|
|
|
});
|
|
|
|
|
|
- // TODO swagger
|
|
|
+ /**
|
|
|
+ * @swagger
|
|
|
+ *
|
|
|
+ * /personal-setting/disassociate-ldap:
|
|
|
+ * put:
|
|
|
+ * tags: [PersonalSetting]
|
|
|
+ * operationId: disassociateLdapAccount
|
|
|
+ * summary: /personal-setting/disassociate-ldap
|
|
|
+ * description: disassociate Ldap account
|
|
|
+ * requestBody:
|
|
|
+ * required: true
|
|
|
+ * content:
|
|
|
+ * application/json:
|
|
|
+ * schema:
|
|
|
+ * $ref: '#/components/schemas/DisassociateUser'
|
|
|
+ * responses:
|
|
|
+ * 200:
|
|
|
+ * description: succeded to disassociate Ldap account
|
|
|
+ * content:
|
|
|
+ * application/json:
|
|
|
+ * schema:
|
|
|
+ * properties:
|
|
|
+ * disassociateUser:
|
|
|
+ * type: object
|
|
|
+ * description: Ldap account disassociate to me
|
|
|
+ */
|
|
|
router.put('/disassociate-ldap', accessTokenParser, loginRequiredStrictly, csrf, validator.disassociateLdap, ApiV3FormValidator, async(req, res) => {
|
|
|
const { user, body } = req;
|
|
|
const { providerType, accountId } = body;
|
|
|
@@ -336,8 +402,8 @@ module.exports = (crowi) => {
|
|
|
if (user.password == null && count <= 1) {
|
|
|
return res.apiv3Err('disassociate-ldap-account-failed');
|
|
|
}
|
|
|
- const account = await ExternalAccount.findOneAndRemove({ providerType, accountId, user });
|
|
|
- return res.apiv3({ account });
|
|
|
+ const disassociateUser = await ExternalAccount.findOneAndRemove({ providerType, accountId, user });
|
|
|
+ return res.apiv3({ disassociateUser });
|
|
|
}
|
|
|
catch (err) {
|
|
|
logger.error(err);
|