SUPPORT-8601: Fix
This commit is contained in:
parent
be451993e4
commit
c849cdb02a
2 changed files with 25 additions and 2 deletions
12
frontend/src/ts/modules/security/EsiaErrorDetail.ts
Normal file
12
frontend/src/ts/modules/security/EsiaErrorDetail.ts
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
class EsiaErrorDetail {
|
||||||
|
private static errors: { [code: string]: string } = {
|
||||||
|
'ESIA-007071': 'Запрос персональных данных по физическим лицам может быть выполнен только с указанием согласий',
|
||||||
|
'ESIA-007055': 'Вход в систему осуществляется с неподтвержденной учетной записью',
|
||||||
|
'ESIA-007036': 'Учетная запись заблокирована',
|
||||||
|
'ESIA-007008': 'Сервис авторизации в настоящее время не может выполнить запрос из-за большой нагрузки или технических работ на сервере',
|
||||||
|
};
|
||||||
|
|
||||||
|
static getDescription(code: string): string {
|
||||||
|
return this.errors[code] || 'Доступ запрещен. Обратитесь к системному администратору. Ошибка ' + code;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -30,8 +30,13 @@ export abstract class AuthGuard implements CanActivate {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (error) {
|
else if (error) {
|
||||||
let errorMessage = error + ', error description =' + errorDescription;
|
let userErrorMessage = 'Произошла неизвестная ошибка. Обратитесь к системному администратору';
|
||||||
this.messageService.error(errorMessage)
|
let errorCode = this.extractCode(errorDescription);
|
||||||
|
if (errorCode) {
|
||||||
|
userErrorMessage = EsiaErrorDetail.getDescription(errorCode);
|
||||||
|
}
|
||||||
|
let errorMessage = error + ', error description = ' + errorDescription;
|
||||||
|
this.messageService.error(userErrorMessage)
|
||||||
throw new Error(errorMessage);
|
throw new Error(errorMessage);
|
||||||
}
|
}
|
||||||
else if (code) {
|
else if (code) {
|
||||||
|
|
@ -62,4 +67,10 @@ export abstract class AuthGuard implements CanActivate {
|
||||||
public getIsAuth(): string {
|
public getIsAuth(): string {
|
||||||
return this.cookieService.get('webbpm.ervu-lkrp-fl');
|
return this.cookieService.get('webbpm.ervu-lkrp-fl');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private extractCode(message: string): string | null {
|
||||||
|
const regex = /ESIA-\d{6}/;
|
||||||
|
const match = message.match(regex);
|
||||||
|
return match ? match[0] : null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue