Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(api): dont cache auth endpoints #4970

Merged
merged 1 commit into from
Dec 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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