Skip to content

Commit

Permalink
fix: auth accross decorator in get account
Browse files Browse the repository at this point in the history
  • Loading branch information
Ihar committed May 8, 2024
1 parent 136410a commit ac07103
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion api-gateway/src/api/service/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { InternalServerErrorDTO } from '../../middlewares/validation/schemas/err
import { ApplicationEnvironment } from '../../environment.js';
import { CACHE } from '../../constants/index.js';
import { UseCache } from '../../helpers/decorators/cache.js';
import { Auth } from '../../auth/auth.decorator.js';

/**
* User account route
Expand Down Expand Up @@ -225,6 +226,7 @@ export class AccountApi {
@HttpCode(HttpStatus.OK)
@Get()
@UseCache()
@Auth(UserRole.STANDARD_REGISTRY)
async getAllAccounts(@Req() req): Promise<AccountsResponseDTO[]> {
const authHeader = req.headers.authorization;
const token = authHeader?.split(' ')[1];
Expand All @@ -240,7 +242,6 @@ export class AccountApi {
throw new HttpException('UNAUTHORIZED', HttpStatus.UNAUTHORIZED);
}
try {
await checkPermission(UserRole.STANDARD_REGISTRY)(user);
return await users.getAllUserAccounts() as any[];
} catch (error) {
new Logger().error(error, ['API_GATEWAY']);
Expand Down

0 comments on commit ac07103

Please sign in to comment.