mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-3181] Auth Guard - redirect by string url (#3474)
* redirect by string url * auth guard tests fix * revise
This commit is contained in:
committed by
Eugenio Romano
parent
0cf2a35983
commit
c0de0d5087
@@ -113,12 +113,12 @@ describe('LoginComponent', () => {
|
||||
spyOn(authService, 'login').and.returnValue(Observable.of({ type: 'type', ticket: 'ticket' }));
|
||||
const redirect = '/home';
|
||||
component.successRoute = redirect;
|
||||
authService.setRedirect({ provider: 'ECM', navigation: ['some-route'] });
|
||||
authService.setRedirect({ provider: 'ECM', url: 'some-route' });
|
||||
|
||||
spyOn(router, 'navigate');
|
||||
spyOn(router, 'navigateByUrl');
|
||||
|
||||
loginWithCredentials('fake-username', 'fake-password');
|
||||
expect(router.navigate).toHaveBeenCalledWith(['some-route']);
|
||||
expect(router.navigateByUrl).toHaveBeenCalledWith('some-route');
|
||||
});
|
||||
|
||||
it('should update user preferences upon login', async(() => {
|
||||
|
@@ -219,16 +219,16 @@ export class LoginComponent implements OnInit {
|
||||
this.authService.login(values.username, values.password, this.rememberMe)
|
||||
.subscribe(
|
||||
(token: any) => {
|
||||
const redirect = this.authService.getRedirect(this.providers);
|
||||
const redirectUrl = this.authService.getRedirect(this.providers);
|
||||
|
||||
this.actualLoginStep = LoginSteps.Welcome;
|
||||
this.userPreferences.setStoragePrefix(values.username);
|
||||
values.password = null;
|
||||
this.success.emit(new LoginSuccessEvent(token, values.username, null));
|
||||
|
||||
if (redirect) {
|
||||
if (redirectUrl) {
|
||||
this.authService.setRedirect(null);
|
||||
this.router.navigate(redirect);
|
||||
this.router.navigateByUrl(redirectUrl);
|
||||
} else if (this.successRoute) {
|
||||
this.router.navigate([this.successRoute]);
|
||||
}
|
||||
|
Reference in New Issue
Block a user