You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@zeppelin.apache.org by pd...@apache.org on 2020/09/21 09:19:16 UTC
[zeppelin] branch branch-0.9 updated: [ZEPPELIN-5043] Support for a
redirect after form login
This is an automated email from the ASF dual-hosted git repository.
pdallig pushed a commit to branch branch-0.9
in repository https://gitbox.apache.org/repos/asf/zeppelin.git
The following commit(s) were added to refs/heads/branch-0.9 by this push:
new c058cdb [ZEPPELIN-5043] Support for a redirect after form login
c058cdb is described below
commit c058cdb1ce58a9a9c9d0854cd469629e48f7c269
Author: Philipp Dallig <ph...@gmail.com>
AuthorDate: Fri Sep 11 15:15:15 2020 +0200
[ZEPPELIN-5043] Support for a redirect after form login
### What is this PR for?
We should redirect the user to the previous location after login.
### What type of PR is it?
- Improvement
### What is the Jira issue?
* https://issues.apache.org/jira/browse/ZEPPELIN-5043
### How should this be tested?
* Travis CI: https://travis-ci.org/github/Reamer/zeppelin/builds/726272032
### Questions:
* Does the licenses files need update? No
* Is there breaking changes for older versions? No
* Does this needs documentation? No
Author: Philipp Dallig <ph...@gmail.com>
Closes #3908 from Reamer/support_from_login_with_redirect and squashes the following commits:
06e0299a4 [Philipp Dallig] Support for a redirect after form login
(cherry picked from commit c9f3616593fcb56371a215b8b872bbacb826b2ab)
Signed-off-by: Philipp Dallig <ph...@gmail.com>
---
.../src/app/pages/login/login.component.ts | 16 +++++++++++++---
.../src/app/pages/workspace/workspace.guard.ts | 2 +-
zeppelin-web/src/app/app.js | 3 ++-
zeppelin-web/src/components/login/login.controller.js | 1 +
4 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/zeppelin-web-angular/src/app/pages/login/login.component.ts b/zeppelin-web-angular/src/app/pages/login/login.component.ts
index 9377249..bd2ce67 100644
--- a/zeppelin-web-angular/src/app/pages/login/login.component.ts
+++ b/zeppelin-web-angular/src/app/pages/login/login.component.ts
@@ -11,7 +11,7 @@
*/
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, OnInit } from '@angular/core';
-import { Router } from '@angular/router';
+import { ActivatedRoute, Router } from '@angular/router';
import { TicketService } from '@zeppelin/services';
@@ -25,6 +25,7 @@ export class LoginComponent implements OnInit {
userName: string;
password: string;
loading = false;
+ private returnUrl: string | undefined;
login() {
this.loading = true;
@@ -32,7 +33,7 @@ export class LoginComponent implements OnInit {
() => {
this.loading = false;
this.cdr.markForCheck();
- this.router.navigate(['/']).then();
+ this.router.navigateByUrl(this.returnUrl || '/');
},
() => {
this.loading = false;
@@ -41,7 +42,16 @@ export class LoginComponent implements OnInit {
);
}
- constructor(private ticketService: TicketService, private cdr: ChangeDetectorRef, private router: Router) {}
+ constructor(
+ private ticketService: TicketService,
+ private cdr: ChangeDetectorRef,
+ private router: Router,
+ private route: ActivatedRoute
+ ) {
+ route.queryParams.subscribe(params => {
+ this.returnUrl = params.returnUrl;
+ });
+ }
ngOnInit() {}
}
diff --git a/zeppelin-web-angular/src/app/pages/workspace/workspace.guard.ts b/zeppelin-web-angular/src/app/pages/workspace/workspace.guard.ts
index b491d75..a0bc7b4 100644
--- a/zeppelin-web-angular/src/app/pages/workspace/workspace.guard.ts
+++ b/zeppelin-web-angular/src/app/pages/workspace/workspace.guard.ts
@@ -30,7 +30,7 @@ export class WorkspaceGuard implements CanActivate {
return this.ticketService.getTicket().pipe(
mapTo(true),
tap(() => this.messageService.bootstrap()),
- catchError(() => of(this.router.createUrlTree(['/login'])))
+ catchError(() => of(this.router.createUrlTree(['/login'], { queryParams: { returnUrl: state.url } })))
);
}
}
diff --git a/zeppelin-web/src/app/app.js b/zeppelin-web/src/app/app.js
index 53d6645..48a285d 100644
--- a/zeppelin-web/src/app/app.js
+++ b/zeppelin-web/src/app/app.js
@@ -221,7 +221,8 @@ function bootstrapApplication() {
$rootScope.$on('$routeChangeStart', function(event, next, current) {
$rootScope.pageTitle = 'Zeppelin';
if (!$rootScope.ticket && next.$$route && !next.$$route.publicAccess) {
- $location.path('/');
+ const oldPath = ($location.search() && $location.search()['ref']) || $location.path();
+ $location.path('/').search('ref', oldPath);
}
});
});
diff --git a/zeppelin-web/src/components/login/login.controller.js b/zeppelin-web/src/components/login/login.controller.js
index 9a42d5f..797b53f 100644
--- a/zeppelin-web/src/components/login/login.controller.js
+++ b/zeppelin-web/src/components/login/login.controller.js
@@ -44,6 +44,7 @@ function LoginCtrl($scope, $rootScope, $http, $httpParamSerializer, baseUrlSrv,
let redirectLocation = $location.search()['ref'];
$location.$$search = {};
$location.path(redirectLocation);
+ $scope.$apply();
}, 100);
}
}, function errorCallback(errorResponse) {