|
|
@@ -7,7 +7,7 @@ import {
|
|
|
NotFoundException,
|
|
|
BadRequestException,
|
|
|
Req,
|
|
|
- Post
|
|
|
+ Post, InternalServerErrorException
|
|
|
} from '@nestjs/common'
|
|
|
import { UsersService } from './users.service'
|
|
|
import { UserProfileDto } from './dto/user-profile.dto'
|
|
|
@@ -20,7 +20,8 @@ import { Public } from 'src/auth/public.decorator'
|
|
|
@Controller('users')
|
|
|
@ApiBearerAuth()
|
|
|
export class UsersController {
|
|
|
- constructor(private readonly usersService: UsersService) {}
|
|
|
+ constructor(private readonly usersService: UsersService) {
|
|
|
+ }
|
|
|
|
|
|
@Get('/my')
|
|
|
public async my(@Req() req) {
|
|
|
@@ -57,6 +58,15 @@ export class UsersController {
|
|
|
await this.usersService.updatePassword(req.user.id, password)
|
|
|
}
|
|
|
|
|
|
+ @Post('/adminUpdatePassword')
|
|
|
+ public async adminUpdatePassword(@Body() { userId, password }, @Req() req) {
|
|
|
+ console.log(req.user.roles)
|
|
|
+ if (req.user.roles.includes('user') || req.user.roles.includes('api')) {
|
|
|
+ throw new InternalServerErrorException('Permission denied!')
|
|
|
+ }
|
|
|
+ await this.usersService.updatePassword(userId, password)
|
|
|
+ }
|
|
|
+
|
|
|
@Get('/invites')
|
|
|
public async invites(@Req() req) {
|
|
|
return this.usersService.getInvites(req.user.id)
|