[ADF-3181] Auth Guard - redirect by string url (#3474)

* redirect by string url

* auth guard tests fix

* revise
This commit is contained in:
Cilibiu Bogdan
2018-06-14 12:19:34 +03:00
committed by Eugenio Romano
parent 0cf2a35983
commit c0de0d5087
12 changed files with 55 additions and 111 deletions

View File

@@ -33,7 +33,7 @@ const REMEMBER_ME_UNTIL = 1000 * 60 * 60 * 24 * 30 ;
@Injectable()
export class AuthenticationService {
private redirect: RedirectionModel = null;
private redirectUrl: RedirectionModel = null;
onLogin: Subject<any> = new Subject<any>();
onLogout: Subject<any> = new Subject<any>();
@@ -249,23 +249,23 @@ export class AuthenticationService {
* @param url URL to redirect to
*/
setRedirect(url: RedirectionModel) {
this.redirect = url;
this.redirectUrl = url;
}
/** Gets the URL to redirect to after login.
* @param provider Service provider. Can be "ECM", "BPM" or "ALL".
* @returns The redirect URL
*/
getRedirect(provider: string): any[] {
return this.hasValidRedirection(provider) ? this.redirect.navigation : null;
getRedirect(provider: string): string {
return this.hasValidRedirection(provider) ? this.redirectUrl.url : null;
}
private hasValidRedirection(provider: string): boolean {
return this.redirect && (this.redirect.provider === provider || this.hasSelectedProviderAll(provider));
return this.redirectUrl && (this.redirectUrl.provider === provider || this.hasSelectedProviderAll(provider));
}
private hasSelectedProviderAll(provider: string): boolean {
return this.redirect && (this.redirect.provider === 'ALL' || provider === 'ALL');
return this.redirectUrl && (this.redirectUrl.provider === 'ALL' || provider === 'ALL');
}
/**