Skip to content

Commit

Permalink
feat: dont cache auth endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
scopsy committed Dec 10, 2023
1 parent 0bae419 commit 4a30034
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion apps/api/src/app/auth/auth.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
UseGuards,
UseInterceptors,
Logger,
ExecutionContext,
Header,
} from '@nestjs/common';
import { MemberRepository, OrganizationRepository, UserRepository, MemberEntity } from '@novu/dal';
import { JwtService } from '@nestjs/jwt';
Expand Down Expand Up @@ -90,13 +90,15 @@ export class AuthController {

@Get('/refresh')
@UseGuards(JwtAuthGuard)
@Header('Cache-Control', 'no-store')
refreshToken(@UserSession() user: IJwtPayload) {
if (!user || !user._id) throw new BadRequestException();

return this.authService.refreshToken(user._id);
}

@Post('/register')
@Header('Cache-Control', 'no-store')
async userRegistration(@Body() body: UserRegistrationBodyDto) {
return await this.userRegisterUsecase.execute(
UserRegisterCommand.create({
Expand Down Expand Up @@ -130,6 +132,7 @@ export class AuthController {
}

@Post('/login')
@Header('Cache-Control', 'no-store')
async userLogin(@Body() body: LoginBodyDto) {
return await this.loginUsecase.execute(
LoginCommand.create({
Expand All @@ -142,6 +145,7 @@ export class AuthController {
@Post('/organizations/:organizationId/switch')
@UseGuards(JwtAuthGuard)
@HttpCode(200)
@Header('Cache-Control', 'no-store')
async organizationSwitch(
@UserSession() user: IJwtPayload,
@Param('organizationId') organizationId: string
Expand All @@ -155,6 +159,7 @@ export class AuthController {
}

@Post('/environments/:environmentId/switch')
@Header('Cache-Control', 'no-store')
@UseGuards(JwtAuthGuard)
@HttpCode(200)
async projectSwitch(
Expand Down

0 comments on commit 4a30034

Please sign in to comment.