HM-115. Добавлена ручка для получения информации о себе по токену, ручка по редактированию инфы о себе по токену
This commit is contained in:
@ -14,6 +14,7 @@ import {
|
||||
UserResponse,
|
||||
CreateUserRequest,
|
||||
UpdateUserRequest,
|
||||
UpdateUserSelf,
|
||||
} from './users.schema';
|
||||
import { Request } from 'express';
|
||||
import {
|
||||
@ -48,7 +49,7 @@ export class UsersController {
|
||||
return this.userService.findAll();
|
||||
}
|
||||
|
||||
@Get(':login')
|
||||
@Get('search/:login')
|
||||
@Header(...ALLOW_ORIGIN_ALL)
|
||||
@ApiResponse(FIND_ONE_SUCCESS)
|
||||
@ApiResponse(FIND_ONE_NOT_FOUND)
|
||||
@ -62,6 +63,22 @@ export class UsersController {
|
||||
return await this.userService.findOne(request.params.login);
|
||||
}
|
||||
|
||||
@Get('me')
|
||||
@Header(...ALLOW_ORIGIN_ALL)
|
||||
async findMe(@Req() request: Request): Promise<UserResponse> {
|
||||
await this.authService.checkRequest(request);
|
||||
|
||||
return this.userService.findMe(request.headers.authorization);
|
||||
}
|
||||
|
||||
@Post('edit-me')
|
||||
@Header(...ALLOW_ORIGIN_ALL)
|
||||
async findEdit(@Req() request: Request<null, UpdateUserSelf>): Promise<UserResponse> {
|
||||
await this.authService.checkRequest(request);
|
||||
|
||||
return this.userService.updateSelf(request.headers.authorization, request.body);
|
||||
}
|
||||
|
||||
@Post()
|
||||
@Header(...ALLOW_ORIGIN_ALL)
|
||||
@ApiResponse(CREATE_SUCCESS)
|
||||
@ -107,7 +124,7 @@ export class UsersController {
|
||||
}
|
||||
|
||||
@Options([
|
||||
'', ':login'
|
||||
'', 'search/:login', ':login', 'me', 'edit-me'
|
||||
])
|
||||
@Header(...ALLOW_ORIGIN_ALL)
|
||||
@Header(...ALLOW_METHOD)
|
||||
|
||||
Reference in New Issue
Block a user