From 2d761b067ec7cb1f4ba02c49f586b2aa3eade019 Mon Sep 17 00:00:00 2001 From: GOKULRAJ136 <110164849+GOKULRAJ136@users.noreply.github.com> Date: Mon, 8 Jan 2024 11:10:04 +0530 Subject: [PATCH] MOSIP-23088 : Added AUTH_ERROR_CODE for authorization security purposes Signed-off-by: GOKULRAJ136 <110164849+GOKULRAJ136@users.noreply.github.com> --- pmp-ui/src/app/app.constants.ts | 2 +- pmp-ui/src/app/core/services/httpinterceptor.ts | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/pmp-ui/src/app/app.constants.ts b/pmp-ui/src/app/app.constants.ts index 9f95bd979..bfbaefcb7 100644 --- a/pmp-ui/src/app/app.constants.ts +++ b/pmp-ui/src/app/app.constants.ts @@ -1,5 +1,5 @@ import * as config from 'src/assets/config.json'; - +export const AUTH_ERROR_CODE = ['KER-ATH-007','KER-ATH-006']; export const VERSION = '1.0'; export const BASE_URL = config.baseUrl; export const IDS = 'dummy'; diff --git a/pmp-ui/src/app/core/services/httpinterceptor.ts b/pmp-ui/src/app/core/services/httpinterceptor.ts index 2ddc529f3..aab056f2e 100644 --- a/pmp-ui/src/app/core/services/httpinterceptor.ts +++ b/pmp-ui/src/app/core/services/httpinterceptor.ts @@ -17,6 +17,7 @@ import { DialogComponent } from 'src/app/shared/dialog/dialog.component'; import { TranslateService } from '@ngx-translate/core'; import { AppConfigService } from 'src/app/app-config.service'; import jwt_decode from "jwt-decode"; +import * as appConstants from 'src/app/app.constants'; @Injectable({ providedIn: 'root' @@ -59,6 +60,13 @@ export class AuthInterceptor implements HttpInterceptor { this.headerService.setRoles(event.body.response.role); this.headerService.setNotificationLanguage(this.decoded["langCode"]); } + if ( + event.body.errors !== null && + (event.body.errors[0]['errorCode'] === + appConstants.AUTH_ERROR_CODE[0] || event.body.errors[0]['errorCode'] === appConstants.AUTH_ERROR_CODE[1]) + ) { + this.redirectService.redirect(window.location.href); + } } } },