You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dlab.apache.org by an...@apache.org on 2019/04/19 13:50:30 UTC

[incubator-dlab] branch DLAB-613 created (now 8ea57be)

This is an automated email from the ASF dual-hosted git repository.

ankovalyshyn pushed a change to branch DLAB-613
in repository https://gitbox.apache.org/repos/asf/incubator-dlab.git.


      at 8ea57be  [DLAB-613][Azure][Data Lake]: fixed issue with login

This branch includes the following new commits:

     new 8ea57be  [DLAB-613][Azure][Data Lake]: fixed issue with login

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@dlab.apache.org
For additional commands, e-mail: commits-help@dlab.apache.org


[incubator-dlab] 01/01: [DLAB-613][Azure][Data Lake]: fixed issue with login

Posted by an...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ankovalyshyn pushed a commit to branch DLAB-613
in repository https://gitbox.apache.org/repos/asf/incubator-dlab.git

commit 8ea57bec567008c58afac67444c6884e6ca0c0b7
Author: Andriana Kovalyshyn <An...@epam.com>
AuthorDate: Fri Apr 19 16:50:11 2019 +0300

    [DLAB-613][Azure][Data Lake]: fixed issue with login
---
 .../core/services/applicationSecurity.service.ts    |  5 +----
 .../src/app/core/services/authorization.guard.ts    | 15 ++++++++++++---
 .../src/app/core/services/checkParams.guard.ts      | 21 +++++++++++----------
 3 files changed, 24 insertions(+), 17 deletions(-)

diff --git a/services/self-service/src/main/resources/webapp/src/app/core/services/applicationSecurity.service.ts b/services/self-service/src/main/resources/webapp/src/app/core/services/applicationSecurity.service.ts
index 45afecc..00be650 100644
--- a/services/self-service/src/main/resources/webapp/src/app/core/services/applicationSecurity.service.ts
+++ b/services/self-service/src/main/resources/webapp/src/app/core/services/applicationSecurity.service.ts
@@ -101,7 +101,6 @@ export class ApplicationSecurityService {
             }
 
             this.storage.destroyToken();
-            this.appRoutingService.redirectToLoginPage();
             return false;
           }),
           catchError(error => {
@@ -111,7 +110,6 @@ export class ApplicationSecurityService {
             return observableOf(false);
           }));
     }
-    this.appRoutingService.redirectToLoginPage();
     this._loggedInStatus.next(false);
     return observableOf(false);
   }
@@ -142,8 +140,7 @@ export class ApplicationSecurityService {
           if (DICTIONARY.cloud_provider === 'azure' && error && error.status === HTTP_STATUS_CODES.FORBIDDEN) {
             window.location.href = error.headers.get('Location');
           } else {
-            const errObj = error.json();
-            this.emmitMessage(errObj.message);
+            this.emmitMessage(error.message);
             return observableOf(false);
           }
         }));
diff --git a/services/self-service/src/main/resources/webapp/src/app/core/services/authorization.guard.ts b/services/self-service/src/main/resources/webapp/src/app/core/services/authorization.guard.ts
index 64519e7..5d07d94 100644
--- a/services/self-service/src/main/resources/webapp/src/app/core/services/authorization.guard.ts
+++ b/services/self-service/src/main/resources/webapp/src/app/core/services/authorization.guard.ts
@@ -18,14 +18,23 @@
  */
 
 import { Injectable } from '@angular/core';
-import { CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';
+import { map } from 'rxjs/operators';
+import { CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot, Router } from '@angular/router';
 import { ApplicationSecurityService } from './applicationSecurity.service';
 
 @Injectable()
 export class AuthorizationGuard implements CanActivate {
-  constructor(private applicationSecurityService: ApplicationSecurityService) { }
+  constructor(
+    private applicationSecurityService: ApplicationSecurityService,
+    private router: Router
+  ) { }
 
   canActivate(next: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
-    return this.applicationSecurityService.isLoggedIn();
+    return this.applicationSecurityService.isLoggedIn().pipe(
+      map(authState => {
+        if (!authState) this.router.navigate(['/login']);
+        return !!authState;
+      })
+    );
   }
 }
diff --git a/services/self-service/src/main/resources/webapp/src/app/core/services/checkParams.guard.ts b/services/self-service/src/main/resources/webapp/src/app/core/services/checkParams.guard.ts
index f294e35..87c4bb2 100644
--- a/services/self-service/src/main/resources/webapp/src/app/core/services/checkParams.guard.ts
+++ b/services/self-service/src/main/resources/webapp/src/app/core/services/checkParams.guard.ts
@@ -18,7 +18,9 @@
  */
 
 import { Injectable } from '@angular/core';
-import { CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';
+import { CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot, Router } from '@angular/router';
+import { Observable } from 'rxjs';
+import { map } from 'rxjs/operators';
 import { ApplicationSecurityService } from './applicationSecurity.service';
 import { AuthorizationGuard } from './authorization.guard';
 
@@ -28,14 +30,13 @@ export class CheckParamsGuard implements CanActivate {
 
   constructor(
     private applicationSecurityService: ApplicationSecurityService,
-    private _authGuard: AuthorizationGuard
+    private _authGuard: AuthorizationGuard,
+    private router: Router
   ) {}
 
-  canActivate(next: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
-    return this._authGuard
-      .canActivate(next, state)
-      .toPromise()
-      .then((auth: boolean) => {
+  canActivate(next: ActivatedRouteSnapshot, state: RouterStateSnapshot):  Observable<any> | Promise<boolean> | boolean {
+    return this.applicationSecurityService.isLoggedIn().pipe(
+      map(authState => {
         const search = document.URL.split('?')[1];
 
         if (search && this.checkParamsCoincidence(search)) {
@@ -49,9 +50,9 @@ export class CheckParamsGuard implements CanActivate {
             .redirectParams(this.result)
             .toPromise();
         }
-
-        return Promise.resolve(!!auth);
-      });
+        if (!authState) this.router.navigate(['/login']);
+        return !!authState;
+      }));
   }
 
   private checkParamsCoincidence(search): boolean {


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@dlab.apache.org
For additional commands, e-mail: commits-help@dlab.apache.org