diff --git a/install/package.json b/install/package.json index 46f9e41a8e..9cbbd90994 100644 --- a/install/package.json +++ b/install/package.json @@ -97,7 +97,7 @@ "nodebb-plugin-spam-be-gone": "0.7.2", "nodebb-rewards-essentials": "0.1.3", "nodebb-theme-lavender": "5.0.14", - "nodebb-theme-persona": "10.2.59", + "nodebb-theme-persona": "10.2.60", "nodebb-theme-slick": "1.2.39", "nodebb-theme-vanilla": "11.2.22", "nodebb-widget-essentials": "4.1.2", diff --git a/public/openapi/write.yaml b/public/openapi/write.yaml index 4d23603ddb..f084ea10b1 100644 --- a/public/openapi/write.yaml +++ b/public/openapi/write.yaml @@ -28,8 +28,255 @@ tags: - name: categories description: Administrative calls to manage categories paths: - /users/: - $ref: 'write/users.yaml' + '/users/{uid}': + delete: + tags: + - users + summary: delete a single user account + parameters: + - in: path + name: uid + schema: + type: integer + required: true + description: uid of the user to delete + responses: + '200': + description: user account deleted + content: + application/json: + schema: + type: object + properties: + status: + $ref: components/schemas/Status.yaml#/Status + response: + type: object + put: + tags: + - users + summary: update a user account + parameters: + - in: path + name: uid + schema: + type: integer + required: true + description: uid of the user to update + requestBody: + required: true + content: + application/json: + schema: + $ref: components/schemas/UserRequest.yaml#/UserRequest + responses: + '200': + description: user profile updated + content: + application/json: + schema: + type: object + properties: + status: + $ref: components/schemas/Status.yaml#/Status + response: + $ref: components/schemas/UserObj.yaml#/UserObj + '401': + $ref: components/responses/401.yaml#/401 + '403': + $ref: components/responses/403.yaml#/403 + '426': + $ref: components/responses/426.yaml#/426 + '500': + $ref: components/responses/500.yaml#/500 + '/users/{uid}/password': + put: + tags: + - users + summary: change a user's password + parameters: + - in: path + name: uid + schema: + type: integer + required: true + description: uid of the user to update + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + currentPassword: + type: string + description: test + example: oldp455word + newPassword: + type: string + example: s3cre7password + required: + - newPassword + responses: + '200': + description: user profile updated + content: + application/json: + schema: + type: object + properties: + status: + $ref: components/schemas/Status.yaml#/Status + response: + type: object + '/users/{uid}/follow': + post: + tags: + - users + summary: follow a user + parameters: + - in: path + name: uid + schema: + type: integer + required: true + description: uid of the user to follow + responses: + '200': + description: successfully followed user + content: + application/json: + schema: + type: object + properties: + status: + $ref: components/schemas/Status.yaml#/Status + response: + type: object + delete: + tags: + - users + summary: unfollows a user + parameters: + - in: path + name: uid + schema: + type: integer + required: true + description: uid of the user to unfollow + responses: + '200': + description: successfully unfollowed user + content: + application/json: + schema: + type: object + properties: + status: + $ref: components/schemas/Status.yaml#/Status + response: + type: object + '/users/{uid}/ban': + put: + tags: + - users + summary: ban a user + parameters: + - in: path + name: uid + schema: + type: integer + required: true + description: uid of the user to ban + requestBody: + content: + application/json: + schema: + type: object + properties: + until: + type: number + description: UNIX timestamp of the ban expiry + example: 1585775608076 + reason: + type: string + example: the reason for the ban + responses: + '200': + description: successfully banned user + content: + application/json: + schema: + type: object + properties: + status: + $ref: components/schemas/Status.yaml#/Status + response: + type: object + delete: + tags: + - users + summary: unbans a user + parameters: + - in: path + name: uid + schema: + type: integer + required: true + description: uid of the user to unban + responses: + '200': + description: successfully unbanned user + content: + application/json: + schema: + type: object + properties: + status: + $ref: components/schemas/Status.yaml#/Status + response: + type: object + '/users/{uid}/tokens': + post: + tags: + - users + summary: generate a user token + description: This route can only be used to generate tokens for the same user. In other words, you cannot use this route to generate a token for a different user than the one you are authenticated as. + responses: + '200': + description: successfully generated a user token + content: + application/json: + schema: + type: object + properties: + status: + $ref: components/schemas/Status.yaml#/Status + response: + type: object + delete: + tags: + - users + summary: delete user token + parameters: + - in: path + name: token + schema: + type: string + required: true + description: a valid API token + responses: + '200': + description: successfully deleted user token + content: + application/json: + schema: + type: object + properties: + status: + $ref: components/schemas/Status.yaml#/Status + response: + type: object /categories/: $ref: 'write/categories.yaml' /groups/: diff --git a/public/openapi/write/users.yaml b/public/openapi/write/users.yaml index c21bf89157..1a0708fb3f 100644 --- a/public/openapi/write/users.yaml +++ b/public/openapi/write/users.yaml @@ -79,252 +79,3 @@ delete: $ref: ../components/schemas/Status.yaml#/Status response: type: object - '/users/{uid}': - delete: - tags: - - users - summary: delete a single user account - parameters: - - in: path - name: uid - schema: - type: integer - required: true - description: uid of the user to delete - responses: - '200': - description: user account deleted - content: - application/json: - schema: - type: object - properties: - status: - $ref: ../components/schemas/Status.yaml#/Status - response: - type: object - put: - tags: - - users - summary: update a user account - parameters: - - in: path - name: uid - schema: - type: integer - required: true - description: uid of the user to update - requestBody: - required: true - content: - application/json: - schema: - $ref: ../components/schemas/UserRequest.yaml#/UserRequest - responses: - '200': - description: user profile updated - content: - application/json: - schema: - type: object - properties: - status: - $ref: ../components/schemas/Status.yaml#/Status - response: - $ref: ../components/schemas/UserObj.yaml#/UserObj - '401': - $ref: ../components/responses/401.yaml#/401 - '403': - $ref: ../components/responses/403.yaml#/403 - '426': - $ref: ../components/responses/426.yaml#/426 - '500': - $ref: ../components/responses/500.yaml#/500 - '/users/{uid}/password': - put: - tags: - - users - summary: change a user's password - parameters: - - in: path - name: uid - schema: - type: integer - required: true - description: uid of the user to update - requestBody: - required: true - content: - application/json: - schema: - type: object - properties: - currentPassword: - type: string - description: test - example: oldp455word - newPassword: - type: string - example: s3cre7password - required: - - newPassword - responses: - '200': - description: user profile updated - content: - application/json: - schema: - type: object - properties: - status: - $ref: ../components/schemas/Status.yaml#/Status - response: - type: object - '/users/{uid}/follow': - post: - tags: - - users - summary: follow a user - parameters: - - in: path - name: uid - schema: - type: integer - required: true - description: uid of the user to follow - responses: - '200': - description: successfully followed user - content: - application/json: - schema: - type: object - properties: - status: - $ref: ../components/schemas/Status.yaml#/Status - response: - type: object - delete: - tags: - - users - summary: unfollows a user - parameters: - - in: path - name: uid - schema: - type: integer - required: true - description: uid of the user to unfollow - responses: - '200': - description: successfully unfollowed user - content: - application/json: - schema: - type: object - properties: - status: - $ref: ../components/schemas/Status.yaml#/Status - response: - type: object - '/users/{uid}/ban': - put: - tags: - - users - summary: ban a user - parameters: - - in: path - name: uid - schema: - type: integer - required: true - description: uid of the user to ban - requestBody: - content: - application/json: - schema: - type: object - properties: - until: - type: number - description: UNIX timestamp of the ban expiry - example: 1585775608076 - reason: - type: string - example: the reason for the ban - responses: - '200': - description: successfully banned user - content: - application/json: - schema: - type: object - properties: - status: - $ref: ../components/schemas/Status.yaml#/Status - response: - type: object - delete: - tags: - - users - summary: unbans a user - parameters: - - in: path - name: uid - schema: - type: integer - required: true - description: uid of the user to unban - responses: - '200': - description: successfully unbanned user - content: - application/json: - schema: - type: object - properties: - status: - $ref: ../components/schemas/Status.yaml#/Status - response: - type: object - '/users/{uid}/tokens': - post: - tags: - - users - summary: generate a user token - description: This route can only be used to generate tokens for the same user. In other words, you cannot use this route to generate a token for a different user than the one you are authenticated as. - responses: - '200': - description: successfully generated a user token - content: - application/json: - schema: - type: object - properties: - status: - $ref: ../components/schemas/Status.yaml#/Status - response: - type: object - delete: - tags: - - users - summary: delete user token - parameters: - - in: path - name: token - schema: - type: string - required: true - description: a valid API token - responses: - '200': - description: successfully deleted user token - content: - application/json: - schema: - type: object - properties: - status: - $ref: ../components/schemas/Status.yaml#/Status - response: - type: object \ No newline at end of file diff --git a/src/user/profile.js b/src/user/profile.js index e6dab413fb..e8f6e5e600 100644 --- a/src/user/profile.js +++ b/src/user/profile.js @@ -326,6 +326,7 @@ module.exports = function (User) { password: hashedPassword, rss_token: utils.generateUUID(), }), + User.reset.cleanByUid(data.uid), User.reset.updateExpiry(data.uid), User.auth.revokeAllSessions(data.uid), ]); diff --git a/test/api.js b/test/api.js index b9493c1df4..a639590e18 100644 --- a/test/api.js +++ b/test/api.js @@ -236,18 +236,15 @@ describe('Read API', async () => { }); describe('Write API', async () => { + const apiPath = path.resolve(__dirname, '../public/openapi/write.yaml'); - // let writeApi; - // const apiPath = path.resolve(__dirname, '../public/openapi/write.yaml'); - - // it('should pass OpenAPI v3 validation', async () => { - // try { - // await SwaggerParser.validate(apiPath); - // } catch (e) { - // assert.ifError(e); - // } - // }); + it('should pass OpenAPI v3 validation', async () => { + try { + await SwaggerParser.validate(apiPath); + } catch (e) { + assert.ifError(e); + } + }); - // writeApi = await SwaggerParser.dereference(apiPath); - // console.log(writeApi); + console.log(await SwaggerParser.dereference(apiPath)); });