Skip to content

Commit

Permalink
chore(skilavottord): Disable IdsUserGuard for all environments except…
Browse files Browse the repository at this point in the history
… prod - more logs (#16544)

* TS-930 disable for all environments except PROD

* TS-930 Add more functions to get the environment

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
birkirkristmunds and kodiakhq[bot] authored Oct 24, 2024
1 parent 350d37a commit 6705e8a
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions apps/skilavottord/ws/src/app/modules/auth/auth.guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import { RolesGuard } from './roles.guard'
import { Role } from './user.model'
import { logger } from '@island.is/logging'

import { isRunningOnEnvironment } from '@island.is/shared/utils'

type AuthorizeOptions = {
roles?: Role[]
}
Expand Down Expand Up @@ -73,12 +75,18 @@ export class AuthGuard implements CanActivate {
export const Authorize = (
{ roles = [] }: AuthorizeOptions = { roles: [] },
): MethodDecorator & ClassDecorator => {
logger.info(`car-recycling: AuthGuard environment #1`, {
environment: process.env.NODE_ENV,
isProduction: isRunningOnEnvironment('production'),
})

// IdsUserGuard is causing constant reload on local and DEV in the skilavottord-web
// To 'fix' it for now we just skip using it for non production
if (process.env.NODE_ENV !== 'production') {
logger.info(`AuthGuard environment`, {
environment: process.env.NODE_ENV,
})
if (
process.env.NODE_ENV !== 'production' ||
!isRunningOnEnvironment('production')
) {
logger.info('`car-recycling: AuthGuard - skipping IdsUserGuard')
return applyDecorators(
SetMetadata('roles', roles),
UseGuards(AuthGuard, RolesGuard),
Expand Down

0 comments on commit 6705e8a

Please sign in to comment.