From 2bcd60df866f354ca9798959c3384622d5cbac8c Mon Sep 17 00:00:00 2001
From: Hamza HRAMCHI <hamza.hramchi@xelians.fr>
Date: Tue, 26 Oct 2021 15:03:04 +0200
Subject: [PATCH] FIX #17590 TIME 0:15 enable/disable menu: check if auth is
 failed

---
 src/frontend/app/login/login.component.ts | 5 ++---
 src/frontend/app/service/auth.guard.ts    | 6 ++++--
 src/frontend/app/service/auth.service.ts  | 1 +
 3 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/src/frontend/app/login/login.component.ts b/src/frontend/app/login/login.component.ts
index 850ca4bc2c..54400abad2 100644
--- a/src/frontend/app/login/login.component.ts
+++ b/src/frontend/app/login/login.component.ts
@@ -86,7 +86,6 @@ export class LoginComponent implements OnInit, AfterViewInit {
                         this.showForm = false;
                         this.authService.saveTokens(data.headers.get('Token'), data.headers.get('Refresh-Token'));
                         this.authService.setUser({});
-
                         if (this.authService.getCachedUrl()) {
                             this.router.navigateByUrl(this.authService.getCachedUrl());
                             this.authService.cleanCachedUrl();
@@ -97,6 +96,7 @@ export class LoginComponent implements OnInit, AfterViewInit {
                     }),
                     catchError((err: any) => {
                         this.loading = false;
+                        this.authService.authFailed = true;
                         if (err.status === 401 && ['kerberos', 'x509', 'azure_saml'].indexOf(this.authService.authMode) === -1) {
                             this.notificationService.error('lang.wrongLoginPassword');
                             loading.dismiss();
@@ -110,8 +110,7 @@ export class LoginComponent implements OnInit, AfterViewInit {
 
                         return of(false);
                     })
-                )
-                .subscribe();
+                ).subscribe();
         } else {
             loading.dismiss();
             this.notificationService.error('lang.requiredLoginPassword');
diff --git a/src/frontend/app/service/auth.guard.ts b/src/frontend/app/service/auth.guard.ts
index 50e552e871..4d9de543d5 100644
--- a/src/frontend/app/service/auth.guard.ts
+++ b/src/frontend/app/service/auth.guard.ts
@@ -45,8 +45,10 @@ export class AuthGuard implements CanActivate {
                 return true;
             }
         } else {
-            this.menu.enable(true, 'left-menu');
-            this.menu.enable(false, 'right-menu');
+            if (!this.authService.authFailed) {
+                this.menu.enable(true, 'left-menu');
+                this.menu.enable(false, 'right-menu');
+            }
             let tokenInfo = this.authService.getToken();
             if (tokenInfo !== null) {
                 if (this.authService.user.id === undefined) {
diff --git a/src/frontend/app/service/auth.service.ts b/src/frontend/app/service/auth.service.ts
index f0468c15e1..913005fa59 100755
--- a/src/frontend/app/service/auth.service.ts
+++ b/src/frontend/app/service/auth.service.ts
@@ -18,6 +18,7 @@ export class AuthService {
     coreUrl: string     = '';
     user: any           = {};
     signatureRoles: any[] = [];
+    authFailed: boolean = false;
 
     constructor(public http: HttpClient,
         private router: Router,
-- 
GitLab