diff --git a/public/openapi/write/users/uid.yaml b/public/openapi/write/users/uid.yaml index 1e2878364a..c8cbcb61b7 100644 --- a/public/openapi/write/users/uid.yaml +++ b/public/openapi/write/users/uid.yaml @@ -15,6 +15,30 @@ head: description: user found '404': description: user not found +get: + tags: + - users + summary: get a single user account + parameters: + - in: path + name: uid + schema: + type: integer + required: true + description: uid of the user to check + example: 3 + responses: + '200': + description: successfully retrieved user profile + content: + application/json: + schema: + type: object + properties: + status: + $ref: ../../components/schemas/Status.yaml#/Status + response: + $ref: ../../components/schemas/UserObj.yaml#/UserObj delete: tags: - users diff --git a/src/controllers/write/users.js b/src/controllers/write/users.js index fc58c4484d..8b7e483ba2 100644 --- a/src/controllers/write/users.js +++ b/src/controllers/write/users.js @@ -43,6 +43,10 @@ Users.exists = async (req, res) => { helpers.formatApiResponse(200, res); }; +Users.get = async (req, res) => { + helpers.formatApiResponse(200, res, await user.getUserData(req.params.uid)); +}; + Users.update = async (req, res) => { const userObj = await api.users.update(req, { ...req.body, uid: req.params.uid }); helpers.formatApiResponse(200, res, userObj); diff --git a/src/routes/write/users.js b/src/routes/write/users.js index 118d8ba27e..43eaf27cda 100644 --- a/src/routes/write/users.js +++ b/src/routes/write/users.js @@ -19,6 +19,7 @@ function authenticatedRoutes() { setupApiRoute(router, 'delete', '/', [...middlewares, middleware.checkRequired.bind(null, ['uids'])], controllers.write.users.deleteMany); setupApiRoute(router, 'head', '/:uid', [middleware.assert.user], controllers.write.users.exists); + setupApiRoute(router, 'get', '/:uid', [...middlewares, middleware.assert.user], controllers.write.users.get); setupApiRoute(router, 'put', '/:uid', [...middlewares, middleware.assert.user], controllers.write.users.update); setupApiRoute(router, 'delete', '/:uid', [...middlewares, middleware.assert.user], controllers.write.users.delete); setupApiRoute(router, 'delete', '/:uid/content', [...middlewares, middleware.assert.user], controllers.write.users.deleteContent);