feat(api): implement /api/user/me/password endpoint
add an endpoint to allow the user to change his password
This commit is contained in:
parent
be1502a4ac
commit
280fa57e45
3 changed files with 171 additions and 0 deletions
43
src/app/api/user/me/password/swagger.ts
Normal file
43
src/app/api/user/me/password/swagger.ts
Normal file
|
@ -0,0 +1,43 @@
|
|||
import { OpenAPIRegistry } from '@asteasolutions/zod-to-openapi';
|
||||
import { FullUserResponseSchema } from '../../validation';
|
||||
import { updateUserPasswordServerSchema } from '../validation';
|
||||
import {
|
||||
invalidRequestDataResponse,
|
||||
notAuthenticatedResponse,
|
||||
serverReturnedDataValidationErrorResponse,
|
||||
userNotFoundResponse,
|
||||
} from '@/lib/defaultApiResponses';
|
||||
|
||||
export default function registerSwaggerPaths(registry: OpenAPIRegistry) {
|
||||
registry.registerPath({
|
||||
method: 'patch',
|
||||
path: '/api/user/me/password',
|
||||
description: 'Update the password of the currently authenticated user',
|
||||
request: {
|
||||
body: {
|
||||
description: 'User password update request body',
|
||||
required: true,
|
||||
content: {
|
||||
'application/json': {
|
||||
schema: updateUserPasswordServerSchema,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
responses: {
|
||||
200: {
|
||||
description: 'User information updated successfully',
|
||||
content: {
|
||||
'application/json': {
|
||||
schema: FullUserResponseSchema,
|
||||
},
|
||||
},
|
||||
},
|
||||
...invalidRequestDataResponse,
|
||||
...notAuthenticatedResponse,
|
||||
...userNotFoundResponse,
|
||||
...serverReturnedDataValidationErrorResponse,
|
||||
},
|
||||
tags: ['User'],
|
||||
});
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue