|
@@ -10,12 +10,12 @@ import { apiV3FormValidator } from '../../middlewares/apiv3-form-validator';
|
|
|
|
|
|
|
|
const logger = loggerFactory('growi:routes:apiv3:users');
|
|
const logger = loggerFactory('growi:routes:apiv3:users');
|
|
|
|
|
|
|
|
|
|
+const path = require('path');
|
|
|
|
|
+
|
|
|
const express = require('express');
|
|
const express = require('express');
|
|
|
|
|
|
|
|
const router = express.Router();
|
|
const router = express.Router();
|
|
|
|
|
|
|
|
-const path = require('path');
|
|
|
|
|
-
|
|
|
|
|
const { body, query } = require('express-validator');
|
|
const { body, query } = require('express-validator');
|
|
|
const { isEmail } = require('validator');
|
|
const { isEmail } = require('validator');
|
|
|
|
|
|
|
@@ -453,12 +453,12 @@ module.exports = (crowi) => {
|
|
|
* @swagger
|
|
* @swagger
|
|
|
*
|
|
*
|
|
|
* paths:
|
|
* paths:
|
|
|
- * /users/{id}/giveAdmin:
|
|
|
|
|
|
|
+ * /users/{id}/grant-admin:
|
|
|
* put:
|
|
* put:
|
|
|
* tags: [Users]
|
|
* tags: [Users]
|
|
|
- * operationId: giveAdminUser
|
|
|
|
|
- * summary: /users/{id}/giveAdmin
|
|
|
|
|
- * description: Give user admin
|
|
|
|
|
|
|
+ * operationId: grantAdminUser
|
|
|
|
|
+ * summary: /users/{id}/grant-admin
|
|
|
|
|
+ * description: Grant user admin
|
|
|
* parameters:
|
|
* parameters:
|
|
|
* - name: id
|
|
* - name: id
|
|
|
* in: path
|
|
* in: path
|
|
@@ -468,7 +468,7 @@ module.exports = (crowi) => {
|
|
|
* type: string
|
|
* type: string
|
|
|
* responses:
|
|
* responses:
|
|
|
* 200:
|
|
* 200:
|
|
|
- * description: Give user admin success
|
|
|
|
|
|
|
+ * description: Grant user admin success
|
|
|
* content:
|
|
* content:
|
|
|
* application/json:
|
|
* application/json:
|
|
|
* schema:
|
|
* schema:
|
|
@@ -477,16 +477,16 @@ module.exports = (crowi) => {
|
|
|
* type: object
|
|
* type: object
|
|
|
* description: data of admin user
|
|
* description: data of admin user
|
|
|
*/
|
|
*/
|
|
|
- router.put('/:id/giveAdmin', loginRequiredStrictly, adminRequired, addActivity, async(req, res) => {
|
|
|
|
|
|
|
+ router.put('/:id/grant-admin', loginRequiredStrictly, adminRequired, addActivity, async(req, res) => {
|
|
|
const { id } = req.params;
|
|
const { id } = req.params;
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
const userData = await User.findById(id);
|
|
const userData = await User.findById(id);
|
|
|
- await userData.makeAdmin();
|
|
|
|
|
|
|
+ await userData.grantAdmin();
|
|
|
|
|
|
|
|
const serializedUserData = serializeUserSecurely(userData);
|
|
const serializedUserData = serializeUserSecurely(userData);
|
|
|
|
|
|
|
|
- activityEvent.emit('update', res.locals.activity._id, { action: SupportedAction.ACTION_ADMIN_USERS_GIVE_ADMIN });
|
|
|
|
|
|
|
+ activityEvent.emit('update', res.locals.activity._id, { action: SupportedAction.ACTION_ADMIN_USERS_GRANT_ADMIN });
|
|
|
|
|
|
|
|
return res.apiv3({ userData: serializedUserData });
|
|
return res.apiv3({ userData: serializedUserData });
|
|
|
}
|
|
}
|
|
@@ -500,40 +500,40 @@ module.exports = (crowi) => {
|
|
|
* @swagger
|
|
* @swagger
|
|
|
*
|
|
*
|
|
|
* paths:
|
|
* paths:
|
|
|
- * /users/{id}/removeAdmin:
|
|
|
|
|
|
|
+ * /users/{id}/revoke-admin:
|
|
|
* put:
|
|
* put:
|
|
|
* tags: [Users]
|
|
* tags: [Users]
|
|
|
- * operationId: removeAdminUser
|
|
|
|
|
- * summary: /users/{id}/removeAdmin
|
|
|
|
|
- * description: Remove user admin
|
|
|
|
|
|
|
+ * operationId: revokeAdminUser
|
|
|
|
|
+ * summary: /users/{id}/revoke-admin
|
|
|
|
|
+ * description: Revoke user admin
|
|
|
* parameters:
|
|
* parameters:
|
|
|
* - name: id
|
|
* - name: id
|
|
|
* in: path
|
|
* in: path
|
|
|
* required: true
|
|
* required: true
|
|
|
- * description: id of user for removing admin
|
|
|
|
|
|
|
+ * description: id of user for revoking admin
|
|
|
* schema:
|
|
* schema:
|
|
|
* type: string
|
|
* type: string
|
|
|
* responses:
|
|
* responses:
|
|
|
* 200:
|
|
* 200:
|
|
|
- * description: Remove user admin success
|
|
|
|
|
|
|
+ * description: Revoke user admin success
|
|
|
* content:
|
|
* content:
|
|
|
* application/json:
|
|
* application/json:
|
|
|
* schema:
|
|
* schema:
|
|
|
* properties:
|
|
* properties:
|
|
|
* userData:
|
|
* userData:
|
|
|
* type: object
|
|
* type: object
|
|
|
- * description: data of removed admin user
|
|
|
|
|
|
|
+ * description: data of revoked admin user
|
|
|
*/
|
|
*/
|
|
|
- router.put('/:id/removeAdmin', loginRequiredStrictly, adminRequired, certifyUserOperationOtherThenYourOwn, addActivity, async(req, res) => {
|
|
|
|
|
|
|
+ router.put('/:id/revoke-admin', loginRequiredStrictly, adminRequired, certifyUserOperationOtherThenYourOwn, addActivity, async(req, res) => {
|
|
|
const { id } = req.params;
|
|
const { id } = req.params;
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
const userData = await User.findById(id);
|
|
const userData = await User.findById(id);
|
|
|
- await userData.removeFromAdmin();
|
|
|
|
|
|
|
+ await userData.revokeAdmin();
|
|
|
|
|
|
|
|
const serializedUserData = serializeUserSecurely(userData);
|
|
const serializedUserData = serializeUserSecurely(userData);
|
|
|
|
|
|
|
|
- activityEvent.emit('update', res.locals.activity._id, { action: SupportedAction.ACTION_ADMIN_USERS_REMOVE_ADMIN });
|
|
|
|
|
|
|
+ activityEvent.emit('update', res.locals.activity._id, { action: SupportedAction.ACTION_ADMIN_USERS_REVOKE_ADMIN });
|
|
|
|
|
|
|
|
return res.apiv3({ userData: serializedUserData });
|
|
return res.apiv3({ userData: serializedUserData });
|
|
|
}
|
|
}
|