diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 18638804..4143840c 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -79,6 +79,9 @@ module.exports = { '@typescript-eslint/no-floating-promises': 'off', '@typescript-eslint/no-non-null-assertion': 'off', '@typescript-eslint/no-unsafe-argument': 'off', + '@typescript-eslint/no-unsafe-assignment': 'off', + '@typescript-eslint/no-unsafe-member-access': 'off', + 'nestjs/use-validation-pipe': 'off', 'import/order': [ 'warn', { diff --git a/src/main.ts b/src/main.ts index 419af707..652b4994 100644 --- a/src/main.ts +++ b/src/main.ts @@ -6,7 +6,6 @@ import { ClassSerializerInterceptor, ValidationPipe } from '@nestjs/common' import { Environment } from '@config/environment' import { AppModule } from '@modules/app' -import { AuthenticationType } from '@modules/auth/enums' import { BEARER } from '@modules/auth/constants' async function bootstrap() { @@ -22,15 +21,7 @@ async function bootstrap() { scheme: BEARER, bearerFormat: 'JWT', }, - AuthenticationType.ACCESS_TOKEN - ) - .addBearerAuth( - { - type: 'http', - scheme: BEARER, - bearerFormat: 'JWT', - }, - AuthenticationType.REFRESH_TOKEN + BEARER ) .build() diff --git a/src/modules/auth/auth.controller.spec.ts b/src/modules/auth/auth.controller.spec.ts index 16150a10..6cd01b9c 100644 --- a/src/modules/auth/auth.controller.spec.ts +++ b/src/modules/auth/auth.controller.spec.ts @@ -4,27 +4,23 @@ import { Test, TestingModule } from '@nestjs/testing' import { AuthController } from './auth.controller' import { SecretData } from './dtos' +import { AuthService } from './auth.service' +import { AuthorizeParams } from './types' import { accessToken, accessTokenMock, - profileMock, refreshToken, userMock, } from '@common/mocks' -import { ProfilesService } from '@modules/profiles' -import { UsersRepository } from '@modules/users' import { SpotifyAuthService } from '@modules/spotify/auth' -import { SpotifyUsersService } from '@modules/spotify/users' describe('AuthController', () => { const redirectUrl = 'http://test.com' let authController: AuthController let spotifyAuthService: SpotifyAuthService - let spotifyUsersService: SpotifyUsersService - let profilesService: ProfilesService - let usersRepository: UsersRepository + let authService: AuthService beforeEach(async () => { const module: TestingModule = await Test.createTestingModule({ @@ -44,22 +40,9 @@ describe('AuthController', () => { }, }, { - provide: ProfilesService, + provide: AuthService, useValue: { - create: vi.fn(), - }, - }, - { - provide: UsersRepository, - useValue: { - createUser: vi.fn(), - findOneByProfileId: vi.fn(), - }, - }, - { - provide: SpotifyUsersService, - useValue: { - profile: vi.fn(), + saveUser: vi.fn(), }, }, ], @@ -67,9 +50,7 @@ describe('AuthController', () => { authController = module.get(AuthController) spotifyAuthService = module.get(SpotifyAuthService) - profilesService = module.get(ProfilesService) - usersRepository = module.get(UsersRepository) - spotifyUsersService = module.get(SpotifyUsersService) + authService = module.get(AuthService) }) test('should be defined', () => { @@ -85,83 +66,28 @@ describe('AuthController', () => { describe('callback', () => { const code = 'code' + const authorizeParams: AuthorizeParams = { + accessToken, + refreshToken, + id: userMock.id, + } test('callback should return valid redirect path', async () => { const tokenSpy = vi .spyOn(spotifyAuthService, 'token') .mockResolvedValue(accessTokenMock) - const profileSpy = vi - .spyOn(spotifyUsersService, 'profile') - .mockResolvedValue(profileMock) - const findOneByProfileIdSpy = vi - .spyOn(usersRepository, 'findOneByProfileId') - .mockResolvedValue(userMock) + const saveUserSpy = vi + .spyOn(authService, 'saveUser') + .mockResolvedValue(authorizeParams) expect(await authController.callback(code)).toEqual({ url: `${redirectUrl}/api/authorize?${new URLSearchParams({ - accessToken, - refreshToken, - id: userMock.id, + ...authorizeParams, }).toString()}`, statusCode: HttpStatus.PERMANENT_REDIRECT, }) expect(tokenSpy).toHaveBeenCalledWith({ code }) - expect(profileSpy).toHaveBeenCalledWith(accessTokenMock) - expect(findOneByProfileIdSpy).toHaveBeenCalledWith(profileMock.id) - }) - - test('should find profile by id', async () => { - vi.spyOn(spotifyAuthService, 'token').mockResolvedValue(accessTokenMock) - vi.spyOn(spotifyUsersService, 'profile').mockResolvedValue(profileMock) - - const findUserByProfileId = vi - .spyOn(usersRepository, 'findOneByProfileId') - .mockResolvedValue(userMock) - const createSpy = vi.spyOn(profilesService, 'create') - const createUserSpy = vi.spyOn(usersRepository, 'createUser') - - expect(await authController.callback(code)).toEqual({ - url: `${redirectUrl}/api/authorize?${new URLSearchParams({ - accessToken, - refreshToken, - id: userMock.id, - }).toString()}`, - statusCode: HttpStatus.PERMANENT_REDIRECT, - }) - expect(findUserByProfileId).toHaveBeenCalledWith(profileMock.id) - expect(createSpy).not.toHaveBeenCalled() - expect(createUserSpy).not.toHaveBeenCalled() - }) - - test('should create profile and user', async () => { - vi.spyOn(spotifyAuthService, 'token').mockResolvedValue(accessTokenMock) - vi.spyOn(spotifyUsersService, 'profile').mockResolvedValue(profileMock) - - const findUserByProfileId = vi.spyOn( - usersRepository, - 'findOneByProfileId' - ) - const createSpy = vi - .spyOn(profilesService, 'create') - .mockResolvedValue(profileMock) - const createUserSpy = vi - .spyOn(usersRepository, 'createUser') - .mockResolvedValue(userMock) - - expect(await authController.callback(code)).toEqual({ - url: `${redirectUrl}/api/authorize?${new URLSearchParams({ - accessToken, - refreshToken, - id: userMock.id, - }).toString()}`, - statusCode: HttpStatus.PERMANENT_REDIRECT, - }) - expect(findUserByProfileId).toHaveBeenCalledWith(profileMock.id) - expect(createSpy).toHaveBeenCalledWith(profileMock) - expect(createUserSpy).toHaveBeenCalledWith({ - profile: profileMock, - refreshToken, - }) + expect(saveUserSpy).toHaveBeenCalledWith(accessTokenMock) }) }) @@ -174,6 +100,8 @@ describe('AuthController', () => { vi.spyOn(spotifyAuthService, 'token').mockResolvedValue(accessTokenMock) - expect(await authController.refresh(refreshToken)).toEqual(secretDataMock) + expect(await authController.refresh({ refreshToken })).toEqual( + secretDataMock + ) }) }) diff --git a/src/modules/auth/auth.controller.ts b/src/modules/auth/auth.controller.ts index d81bbf12..de576541 100644 --- a/src/modules/auth/auth.controller.ts +++ b/src/modules/auth/auth.controller.ts @@ -1,14 +1,15 @@ import { + Body, Controller, Get, HttpStatus, - Inject, + Post, Query, Redirect, - forwardRef, } from '@nestjs/common' import { ConfigService } from '@nestjs/config' import { + ApiBody, ApiExcludeEndpoint, ApiOkResponse, ApiOperation, @@ -17,15 +18,11 @@ import { import { spotifyAuthorizationScopes } from './config' import { RedirectResponse } from './types' -import { Token, ApiAuth } from './decorators' -import { SecretData } from './dtos' +import { RefreshToken, SecretData } from './dtos' +import { AuthService } from './auth.service' import { SpotifyAuthService } from '@modules/spotify/auth' import { Environment } from '@config/environment' -import { AuthenticationType } from '@modules/auth/enums' -import { UsersRepository } from '@modules/users' -import { ProfilesService } from '@modules/profiles' -import { SpotifyUsersService } from '@modules/spotify/users' import { adaptSecretData } from '@common/adapters' const { @@ -40,11 +37,8 @@ const { export class AuthController { constructor( private readonly configService: ConfigService, - @Inject(forwardRef(() => ProfilesService)) - private readonly profilesService: ProfilesService, - private readonly usersRepository: UsersRepository, - private readonly spotifyAuthService: SpotifyAuthService, - private readonly spotifyUsersService: SpotifyUsersService + private readonly authService: AuthService, + private readonly spotifyAuthService: SpotifyAuthService ) {} @Get('login') @@ -75,53 +69,29 @@ export class AuthController { const token = await this.spotifyAuthService.token({ code, }) - const spotifyProfile = await this.spotifyUsersService.profile(token) - const foundUser = await this.usersRepository.findOneByProfileId( - spotifyProfile.id - ) - - const { access_token: accessToken, refresh_token: refreshToken } = token - - if (refreshToken) { - let id: string - - if (foundUser) { - id = foundUser.id - } else { - const profile = await this.profilesService.create(spotifyProfile) - - const { id: createdUserId } = await this.usersRepository.createUser({ - profile, - refreshToken, - }) - - id = createdUserId - } - - return { - url: `${this.configService.get( - CLIENT_CALLBACK_URL - )}/api/authorize?${new URLSearchParams({ - accessToken, - refreshToken, - id, - }).toString()}`, - statusCode: HttpStatus.PERMANENT_REDIRECT, - } + return { + url: `${this.configService.get( + CLIENT_CALLBACK_URL + )}/api/authorize?${new URLSearchParams({ + ...(await this.authService.saveUser(token)), + }).toString()}`, + statusCode: HttpStatus.PERMANENT_REDIRECT, } } - @Get('refresh') + @Post('refresh') @ApiOperation({ summary: 'Refreshing access token.', }) - @ApiAuth(AuthenticationType.REFRESH_TOKEN) @ApiOkResponse({ description: 'Access token has been succesfully refreshed', type: SecretData, }) - refresh(@Token() refreshToken: string) { + @ApiBody({ + type: RefreshToken, + }) + refresh(@Body() { refreshToken }: RefreshToken) { return this.spotifyAuthService.token({ refreshToken }).then(adaptSecretData) } } diff --git a/src/modules/auth/auth.service.spec.ts b/src/modules/auth/auth.service.spec.ts index db236aff..96c83075 100644 --- a/src/modules/auth/auth.service.spec.ts +++ b/src/modules/auth/auth.service.spec.ts @@ -1,144 +1,105 @@ -import { URLSearchParams } from 'node:url' - -import { HttpService } from '@nestjs/axios' -import { ConfigService } from '@nestjs/config' -import { JwtService } from '@nestjs/jwt' -import { Test, TestingModule } from '@nestjs/testing' -import { Profile } from 'passport-spotify' -import { of } from 'rxjs' +import { Test } from '@nestjs/testing' import { AuthService } from './auth.service' -import { spotifyProfileMock, profileMock } from '@common/mocks' +import { accessToken, refreshToken } from '@common/mocks' +import { profileMock, userMock, accessTokenMock } from '@common/mocks' +import { UsersRepository } from '@modules/users' +import { ProfilesService } from '@modules/profiles' +import { SpotifyUsersService } from '@modules/spotify/users' describe('AuthService', () => { let authService: AuthService - let jwtService: JwtService - let httpService: HttpService - let configService: ConfigService + let usersRepository: UsersRepository + let profilesService: ProfilesService + let spotifyUsersService: SpotifyUsersService beforeEach(async () => { - const module: TestingModule = await Test.createTestingModule({ + const module = await Test.createTestingModule({ providers: [ AuthService, - { - provide: JwtService, + provide: UsersRepository, useValue: { - sign: vi.fn(), + findOneByProfileId: vi.fn(), + createUser: vi.fn(), }, }, { - provide: HttpService, + provide: ProfilesService, useValue: { - post: vi.fn(), - get: vi.fn(), + create: vi.fn(), }, }, { - provide: ConfigService, + provide: SpotifyUsersService, useValue: { - get: vi.fn(), + profile: vi.fn(), }, }, ], }).compile() - authService = module.get(AuthService) - jwtService = module.get(JwtService) - httpService = module.get(HttpService) - configService = module.get(ConfigService) + authService = module.get(AuthService) + usersRepository = module.get(UsersRepository) + profilesService = module.get(ProfilesService) + spotifyUsersService = module.get(SpotifyUsersService) }) test('should be defined', () => { expect(authService).toBeDefined() }) - test('should login', () => { - const profile: Profile = { - provider: 'spotify', - id: '123', - displayName: 'John Doe', - username: 'john.doe', - photos: ['example'], - profileUrl: 'example.com', - country: 'US', - followers: 0, - product: 'premium', - _raw: 'raw', - _json: {}, - } - - jwtService.sign = vi.fn().mockReturnValue('token') - - expect(authService.login(profile)).toBe('token') - }) - - describe('token', () => { - test('should refresh token', async () => { - configService.get = vi.fn().mockReturnValue('value') - - const response = { - data: { - access_token: 'token', - expires_in: 3600, - }, - } - - const expectedResponse = { - accessToken: 'token', - expiresIn: 3600, - } - - httpService.post = vi - .fn() - .mockImplementation((_url, parameters: URLSearchParams) => { - if (parameters.get('grant_type') === 'refresh_token') - return of(response) - }) - - expect(await authService.token({ refreshToken: 'refresh' })).toEqual( - expectedResponse + describe('saveUser', () => { + test('should create new user', async () => { + const profileSpy = vi + .spyOn(spotifyUsersService, 'profile') + .mockResolvedValue(profileMock) + const findOneByProfileIdSpy = vi.spyOn( + usersRepository, + 'findOneByProfileId' ) + const createSpy = vi + .spyOn(profilesService, 'create') + .mockResolvedValue(profileMock) + const createUserSpy = vi + .spyOn(usersRepository, 'createUser') + .mockResolvedValue(userMock) + + expect(await authService.saveUser(accessTokenMock)).toEqual({ + accessToken, + refreshToken, + id: userMock.id, + }) + expect(profileSpy).toHaveBeenCalledWith(accessTokenMock) + expect(findOneByProfileIdSpy).toHaveBeenCalledWith(profileMock.id) + expect(createSpy).toHaveBeenCalledWith(profileMock) + expect(createUserSpy).toHaveBeenCalledWith({ + profile: profileMock, + refreshToken, + }) }) - test('should authorize and get tokens', async () => { - configService.get = vi.fn().mockReturnValue('value') - - const response = { - data: { - access_token: 'token', - refresh_token: 'refresh', - expires_in: 3600, - }, - } - - const expectedResponse = { - accessToken: 'token', - refreshToken: 'refresh', - expiresIn: 3600, - } - - httpService.post = vi - .fn() - .mockImplementation((_url, parameters: URLSearchParams) => { - if (parameters.get('grant_type') === 'authorization_code') - return of(response) - }) - - expect(await authService.token({ code: 'code' })).toEqual( - expectedResponse - ) + test('should return existing user', async () => { + const profileSpy = vi + .spyOn(spotifyUsersService, 'profile') + .mockResolvedValue(profileMock) + const findOneByProfileIdSpy = vi + .spyOn(usersRepository, 'findOneByProfileId') + .mockResolvedValue(userMock) + const createSpy = vi.spyOn(profilesService, 'create') + + const createUserSpy = vi.spyOn(usersRepository, 'createUser') + + expect(await authService.saveUser(accessTokenMock)).toEqual({ + accessToken, + refreshToken, + id: userMock.id, + }) + expect(profileSpy).toHaveBeenCalledWith(accessTokenMock) + expect(findOneByProfileIdSpy).toHaveBeenCalledWith(profileMock.id) + expect(createSpy).not.toHaveBeenCalled() + expect(createUserSpy).not.toHaveBeenCalled() }) }) - - test('should return profile', async () => { - const response = { - data: spotifyProfileMock, - } - - httpService.get = vi.fn().mockReturnValue(of(response)) - - expect(await authService.profile('token')).toEqual(profileMock) - }) }) diff --git a/src/modules/auth/auth.service.ts b/src/modules/auth/auth.service.ts index 3e7945e5..6c8e56f6 100644 --- a/src/modules/auth/auth.service.ts +++ b/src/modules/auth/auth.service.ts @@ -1,89 +1,48 @@ -import { HttpService } from '@nestjs/axios' import { Injectable } from '@nestjs/common' -import { ConfigService } from '@nestjs/config' -import { JwtService } from '@nestjs/jwt' -import { Profile as PassportSpotifyProfile } from 'passport-spotify' -import { map, catchError, firstValueFrom } from 'rxjs' +import { AccessToken } from '@spotify/web-api-ts-sdk' -import { SecretData } from './dtos' -import { TokenOptions } from './types' +import { AuthorizeParams } from './types' -import { Environment } from '@config/environment' -import { SpotifyToken, Profile, SpotifyProfile } from '@common/types/spotify' -import { applyAuthorizationHeader, catchSpotifyError } from '@common/utils' -import { adaptProfile, adaptSecretData } from '@common/adapters' +import { UsersRepository } from '@modules/users' +import { ProfilesService } from '@modules/profiles' +import { SpotifyUsersService } from '@modules/spotify/users' @Injectable() export class AuthService { constructor( - private readonly jwtService: JwtService, - private readonly httpService: HttpService, - private readonly configService: ConfigService + private readonly usersRepository: UsersRepository, + private readonly profilesService: ProfilesService, + private readonly spotifyUsersService: SpotifyUsersService ) {} - login({ id, username }: PassportSpotifyProfile) { - const payload = { - name: username, - sub: id, - } - - return this.jwtService.sign(payload) - } + async saveUser(token: AccessToken): Promise { + const spotifyProfile = await this.spotifyUsersService.profile(token) - token({ refreshToken, code }: TokenOptions): Promise { - const url = `${this.configService.get( - Environment.SPOTIFY_ACCOUNTS_URL - )}/api/token` - const cliendId = this.configService.get( - Environment.SPOTIFY_CLIENT_ID - ) - const clientSecret = this.configService.get( - Environment.SPOTIFY_CLIENT_SECRET - ) - const callbackUrl = this.configService.get( - Environment.SPOTIFY_CALLBACK_URL + const foundUser = await this.usersRepository.findOneByProfileId( + spotifyProfile.id ) - const bufferedCredentials = Buffer.from( - `${cliendId}:${clientSecret}` - ).toString('base64') - const params = new URLSearchParams() + const { access_token: accessToken, refresh_token: refreshToken } = token - if (refreshToken) { - params.append('refresh_token', refreshToken) - params.append('grant_type', 'refresh_token') - } - if (code) { - params.append('code', code) - params.append('grant_type', 'authorization_code') - callbackUrl && params.append('redirect_uri', callbackUrl) - } + let id: string - return firstValueFrom( - this.httpService - .post(url, params, { - headers: { - 'Content-Type': 'application/x-www-form-urlencoded', - Authorization: `Basic ${bufferedCredentials}`, - }, - }) - .pipe( - map(response => response.data), - map(adaptSecretData), - catchError(catchSpotifyError) - ) - ) - } + if (foundUser) { + id = foundUser.id + } else { + const profile = await this.profilesService.create(spotifyProfile) - profile(accessToken: string): Promise { - return firstValueFrom( - this.httpService - .get('/me', applyAuthorizationHeader(accessToken)) - .pipe( - map(response => response.data), - map(adaptProfile), - catchError(catchSpotifyError) - ) - ) + const createdUser = await this.usersRepository.createUser({ + profile, + refreshToken, + }) + + id = createdUser.id + } + + return { + accessToken, + refreshToken, + id, + } } } diff --git a/src/modules/auth/decorators/api-auth.decorator.ts b/src/modules/auth/decorators/api-auth.decorator.ts index 76424a52..ec339254 100644 --- a/src/modules/auth/decorators/api-auth.decorator.ts +++ b/src/modules/auth/decorators/api-auth.decorator.ts @@ -1,9 +1,9 @@ import { applyDecorators } from '@nestjs/common' import { ApiBearerAuth, ApiUnauthorizedResponse } from '@nestjs/swagger' -import { AuthenticationType } from '../enums' +import { BEARER } from '../constants' -export const ApiAuth = (authenticationType: AuthenticationType) => +export const ApiAuth = () => applyDecorators( ApiUnauthorizedResponse({ description: 'The access token expired', @@ -14,5 +14,5 @@ export const ApiAuth = (authenticationType: AuthenticationType) => ApiUnauthorizedResponse({ description: 'No value was provided for Authentication', }), - ApiBearerAuth(authenticationType) + ApiBearerAuth(BEARER) ) diff --git a/src/modules/auth/dtos/index.ts b/src/modules/auth/dtos/index.ts index 7e7b0380..a51c7af7 100644 --- a/src/modules/auth/dtos/index.ts +++ b/src/modules/auth/dtos/index.ts @@ -1 +1,2 @@ export * from './secret-data.dto' +export * from './refresh-token.dto' diff --git a/src/modules/auth/dtos/refresh-token.dto.ts b/src/modules/auth/dtos/refresh-token.dto.ts new file mode 100644 index 00000000..b4dcdd54 --- /dev/null +++ b/src/modules/auth/dtos/refresh-token.dto.ts @@ -0,0 +1,8 @@ +import { ApiProperty } from '@nestjs/swagger' +import { IsString } from 'class-validator' + +export abstract class RefreshToken { + @ApiProperty() + @IsString() + refreshToken: string +} diff --git a/src/modules/auth/enums/authentication-type.enum.ts b/src/modules/auth/enums/authentication-type.enum.ts deleted file mode 100644 index 29908430..00000000 --- a/src/modules/auth/enums/authentication-type.enum.ts +++ /dev/null @@ -1,4 +0,0 @@ -export enum AuthenticationType { - ACCESS_TOKEN = 'access-token', - REFRESH_TOKEN = 'refresh-token', -} diff --git a/src/modules/auth/enums/index.ts b/src/modules/auth/enums/index.ts deleted file mode 100644 index 70e512af..00000000 --- a/src/modules/auth/enums/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './authentication-type.enum' diff --git a/src/modules/auth/types/authorize-params.type.ts b/src/modules/auth/types/authorize-params.type.ts new file mode 100644 index 00000000..a495a50e --- /dev/null +++ b/src/modules/auth/types/authorize-params.type.ts @@ -0,0 +1,5 @@ +export interface AuthorizeParams { + refreshToken: string + accessToken: string + id: string +} diff --git a/src/modules/auth/types/index.ts b/src/modules/auth/types/index.ts index d3b323f5..afbb7c99 100644 --- a/src/modules/auth/types/index.ts +++ b/src/modules/auth/types/index.ts @@ -1,3 +1,2 @@ -export * from './jwt-payload' -export * from './redirect-response' -export * from './token-options' +export * from './authorize-params.type' +export * from './redirect-response.type' diff --git a/src/modules/auth/types/jwt-payload.ts b/src/modules/auth/types/jwt-payload.ts deleted file mode 100644 index 1bf619f8..00000000 --- a/src/modules/auth/types/jwt-payload.ts +++ /dev/null @@ -1,4 +0,0 @@ -export interface JwtPayload { - name: string - sub: string -} diff --git a/src/modules/auth/types/redirect-response.ts b/src/modules/auth/types/redirect-response.type.ts similarity index 100% rename from src/modules/auth/types/redirect-response.ts rename to src/modules/auth/types/redirect-response.type.ts diff --git a/src/modules/auth/types/token-options.ts b/src/modules/auth/types/token-options.ts deleted file mode 100644 index 99ceca5d..00000000 --- a/src/modules/auth/types/token-options.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { RequireOnlyOne } from '@common/types/utils' - -export type TokenOptions = RequireOnlyOne<{ - refreshToken?: string - code?: string -}> diff --git a/src/modules/users/users-playback.controller.ts b/src/modules/users/users-playback.controller.ts index 246f9eb8..d76e5b07 100644 --- a/src/modules/users/users-playback.controller.ts +++ b/src/modules/users/users-playback.controller.ts @@ -25,14 +25,13 @@ import { ONE_SUCCESFULLY_FOUND, } from '@common/constants' import { ApiAuth, Token } from '@modules/auth/decorators' -import { AuthenticationType } from '@modules/auth/enums' import { SpotifyAuthService } from '@modules/spotify/auth' import { SpotifyPlayerService } from '@modules/spotify/player' import { Success } from '@common/dtos' @Controller('users/:id/playback') @ApiTags('users/{id}/playback') -@ApiAuth(AuthenticationType.ACCESS_TOKEN) +@ApiAuth() export class UsersPlaybackController { constructor( private readonly usersRepository: UsersRepository, diff --git a/src/modules/users/users-profile.controller.ts b/src/modules/users/users-profile.controller.ts index 517e9597..f952788d 100644 --- a/src/modules/users/users-profile.controller.ts +++ b/src/modules/users/users-profile.controller.ts @@ -26,14 +26,13 @@ import { ONE_IS_INVALID, } from '@common/constants' import { ApiAuth, Token } from '@modules/auth/decorators' -import { AuthenticationType } from '@modules/auth/enums' import { SpotifyAuthService } from '@modules/spotify/auth' import { SpotifyUsersService } from '@modules/spotify/users' import { SpotifyPlayerService } from '@modules/spotify/player' @Controller('users/:id/profile') @ApiTags('users/{id}/profile') -@ApiAuth(AuthenticationType.ACCESS_TOKEN) +@ApiAuth() export class UsersProfileController { constructor( private readonly usersRepository: UsersRepository, diff --git a/src/modules/users/users.controller.ts b/src/modules/users/users.controller.ts index 8eca0d06..05f2ca55 100644 --- a/src/modules/users/users.controller.ts +++ b/src/modules/users/users.controller.ts @@ -29,12 +29,11 @@ import { ONE_IS_INVALID, ONE_SUCCESFULLY_FOUND, } from '@common/constants' -import { AuthenticationType } from '@modules/auth/enums' import { ApiAuth, Token } from '@modules/auth/decorators' @Controller(USERS) @ApiTags(USERS) -@ApiAuth(AuthenticationType.ACCESS_TOKEN) +@ApiAuth() export class UsersController { constructor(private readonly usersRepository: UsersRepository) {}