Skip to content

Commit

Permalink
MOSIP-23088 : Added AUTH_ERROR_CODE for authorization security purposes
Browse files Browse the repository at this point in the history
Signed-off-by: GOKULRAJ136 <[email protected]>
  • Loading branch information
GOKULRAJ136 committed Jan 25, 2024
1 parent 94a4e44 commit 2d761b0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pmp-ui/src/app/app.constants.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
8 changes: 8 additions & 0 deletions pmp-ui/src/app/core/services/httpinterceptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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);
}
}
}
},
Expand Down

0 comments on commit 2d761b0

Please sign in to comment.