Should not redirect if is SilentLogin on (#5216)

* fix redirect

* fix lint

* remove false behaviour alrady tested in the new unit test

* Update auth-guard-base.ts
This commit is contained in:
Eugenio Romano
2019-11-06 13:56:01 +02:00
committed by Denys Vuika
parent 3c1097fb84
commit 5578b7b851
4 changed files with 27 additions and 38 deletions

View File

@@ -64,12 +64,14 @@ export abstract class AuthGuardBase implements CanActivate, CanActivateChild {
}
protected redirectToUrl(provider: string, url: string) {
this.authenticationService.setRedirect({ provider, url });
if (!this.isSilentLogin()) {
this.authenticationService.setRedirect({ provider, url });
const pathToLogin = this.getLoginRoute();
const urlToRedirect = `/${pathToLogin}?redirectUrl=${url}`;
const pathToLogin = this.getLoginRoute();
const urlToRedirect = `/${pathToLogin}?redirectUrl=${url}`;
this.router.navigateByUrl(urlToRedirect);
this.router.navigateByUrl(urlToRedirect);
}
}
protected getLoginRoute(): string {
@@ -91,4 +93,13 @@ export abstract class AuthGuardBase implements CanActivate, CanActivateChild {
this.authenticationService.isOauth() && !!oauth && !oauth.silentLogin
);
}
protected isSilentLogin(): boolean {
const oauth = this.appConfigService.get<OauthConfigModel>(
AppConfigValues.OAUTHCONFIG,
null
);
return this.authenticationService.isOauth() && oauth && oauth.silentLogin;
}
}