mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-13 13:03:04 +00:00
Redirect after login changed to use Router navigateByUrl() to prevent encoding of query parameters in redirect.
This commit is contained in:
@@ -249,30 +249,34 @@ describe('AuthService test', () => {
|
||||
|
||||
it ('should set redirect url to previous page', () => {
|
||||
spyOn(routeServiceMock, 'getHistory').and.callThrough();
|
||||
spyOn(routerStub, 'navigateByUrl');
|
||||
authService.redirectAfterLoginSuccess(true);
|
||||
expect(routeServiceMock.getHistory).toHaveBeenCalled();
|
||||
expect(routerStub.navigate).toHaveBeenCalledWith(['/collection/123']);
|
||||
expect(routerStub.navigateByUrl).toHaveBeenCalledWith('/collection/123');
|
||||
});
|
||||
|
||||
it ('should set redirect url to current page', () => {
|
||||
spyOn(routeServiceMock, 'getHistory').and.callThrough();
|
||||
spyOn(routerStub, 'navigateByUrl');
|
||||
authService.redirectAfterLoginSuccess(false);
|
||||
expect(routeServiceMock.getHistory).toHaveBeenCalled();
|
||||
expect(routerStub.navigate).toHaveBeenCalledWith(['/home']);
|
||||
expect(routerStub.navigateByUrl).toHaveBeenCalledWith('/home');
|
||||
});
|
||||
|
||||
it ('should redirect to / and not to /login', () => {
|
||||
spyOn(routeServiceMock, 'getHistory').and.returnValue(observableOf(['/login', '/login']));
|
||||
spyOn(routerStub, 'navigateByUrl');
|
||||
authService.redirectAfterLoginSuccess(true);
|
||||
expect(routeServiceMock.getHistory).toHaveBeenCalled();
|
||||
expect(routerStub.navigate).toHaveBeenCalledWith(['/']);
|
||||
expect(routerStub.navigateByUrl).toHaveBeenCalledWith('/');
|
||||
});
|
||||
|
||||
it ('should redirect to / when no redirect url is found', () => {
|
||||
spyOn(routeServiceMock, 'getHistory').and.returnValue(observableOf(['']));
|
||||
spyOn(routerStub, 'navigateByUrl');
|
||||
authService.redirectAfterLoginSuccess(true);
|
||||
expect(routeServiceMock.getHistory).toHaveBeenCalled();
|
||||
expect(routerStub.navigate).toHaveBeenCalledWith(['/']);
|
||||
expect(routerStub.navigateByUrl).toHaveBeenCalledWith('/');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user