This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
import { Controller, Post, Body, HttpCode, HttpStatus } from '@nestjs/common';
|
||||
import { Controller, Post, Body, HttpCode, HttpStatus, Req, UseGuards } from '@nestjs/common';
|
||||
import { Throttle } from '@nestjs/throttler';
|
||||
import { ApiTags, ApiOperation } from '@nestjs/swagger';
|
||||
import { ApiTags, ApiOperation, ApiBearerAuth } from '@nestjs/swagger';
|
||||
import { AuthService } from './auth.service';
|
||||
import { LoginDto } from './dto/login.dto';
|
||||
import { RefreshTokenDto } from './dto/refresh-token.dto';
|
||||
import { ChangePasswordDto } from './dto/change-password.dto';
|
||||
import { JwtAuthGuard } from './guards/jwt-auth.guard';
|
||||
|
||||
@ApiTags('Authentication')
|
||||
@Controller('auth')
|
||||
@@ -32,4 +34,14 @@ export class AuthController {
|
||||
await this.authService.logout(dto.refreshToken);
|
||||
return { ok: true };
|
||||
}
|
||||
|
||||
@Post('change-password')
|
||||
@Throttle({ default: { limit: 10, ttl: 60000 } })
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@ApiBearerAuth()
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@ApiOperation({ summary: "Change the signed-in user's password; signs out their other sessions and returns new tokens" })
|
||||
async changePassword(@Body() dto: ChangePasswordDto, @Req() req: any) {
|
||||
return this.authService.changePassword(req.user.id, dto.currentPassword, dto.newPassword);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user