diff --git a/ui-ngx/src/app/core/auth/auth.service.ts b/ui-ngx/src/app/core/auth/auth.service.ts index 0faf7d6769..fad2a5e145 100644 --- a/ui-ngx/src/app/core/auth/auth.service.ts +++ b/ui-ngx/src/app/core/auth/auth.service.ts @@ -43,6 +43,8 @@ import { DashboardInfo } from '@shared/models/dashboard.models'; import { PageData } from '@app/shared/models/page/page-data'; import { AdminService } from '@core/http/admin.service'; import { ActionNotificationShow } from '@core/notification/notification.actions'; +import { MatDialog, MatDialogConfig } from '@angular/material/dialog'; +import { AlertDialogComponent } from '@shared/components/dialog/alert-dialog.component'; @Injectable({ providedIn: 'root' @@ -60,7 +62,8 @@ export class AuthService { private utils: UtilsService, private dashboardService: DashboardService, private adminService: AdminService, - private translate: TranslateService + private translate: TranslateService, + private dialog: MatDialog ) { } @@ -273,6 +276,7 @@ export class AuthService { const refreshToken = this.utils.getQueryParam('refreshToken'); const username = this.utils.getQueryParam('username'); const password = this.utils.getQueryParam('password'); + const loginError = this.utils.getQueryParam('loginError'); if (publicId) { return this.publicLogin(publicId).pipe( mergeMap((response) => { @@ -317,6 +321,10 @@ export class AuthService { } ) ); + } else if (loginError) { + this.showLoginErrorDialog(loginError); + this.utils.updateQueryParam('loginError', null); + return throwError(Error()); } return this.procceedJwtTokenValidate(doTokenRefresh); } else { @@ -324,6 +332,22 @@ export class AuthService { } } + private showLoginErrorDialog(loginError: string) { + this.translate.get(['login.error', 'action.close']).subscribe( + (translations) => { + const dialogConfig: MatDialogConfig = { + disableClose: true, + data: { + title: translations['login.error'], + message: loginError, + ok: translations['action.close'] + } + }; + this.dialog.open(AlertDialogComponent, dialogConfig); + } + ); + } + private procceedJwtTokenValidate(doTokenRefresh?: boolean): Observable { const loadUserSubject = new ReplaySubject(); this.validateJwtToken(doTokenRefresh).subscribe( diff --git a/ui-ngx/src/assets/locale/locale.constant-en_US.json b/ui-ngx/src/assets/locale/locale.constant-en_US.json index 54b7eca099..2a7b7b8f8a 100644 --- a/ui-ngx/src/assets/locale/locale.constant-en_US.json +++ b/ui-ngx/src/assets/locale/locale.constant-en_US.json @@ -1355,7 +1355,8 @@ "password-link-sent-message": "Password reset link was successfully sent!", "email": "Email", "login-with": "Login with {{name}}", - "or": "or" + "or": "or", + "error": "Login error" }, "position": { "top": "Top",