[ADF-3191] Fix userprefrence oauth2 (#3488)

* remove user preference setting save

* fix host setting test

* remove userPreferences test

* fix title service test

* remove unused imports

* restore input align

* fix service import in test tag rating
This commit is contained in:
Eugenio Romano
2018-06-15 08:32:16 +01:00
committed by GitHub
parent af2cde0791
commit 8966e22487
43 changed files with 417 additions and 528 deletions

View File

@@ -20,14 +20,14 @@ import {
ActivatedRouteSnapshot, CanActivate, RouterStateSnapshot, Router
} from '@angular/router';
import { AuthenticationService } from './authentication.service';
import { AppConfigService } from '../app-config/app-config.service';
import { AppConfigService, AppConfigValues } from '../app-config/app-config.service';
import { OauthConfigModel } from '../models/oauth-config.model';
@Injectable()
export class AuthGuardEcm implements CanActivate {
constructor(
private authService: AuthenticationService,
private router: Router,
private appConfig: AppConfigService) {
constructor(private authService: AuthenticationService,
private router: Router,
private appConfig: AppConfigService) {
}
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean {
@@ -43,16 +43,23 @@ export class AuthGuardEcm implements CanActivate {
return true;
}
this.authService.setRedirect({ provider: 'ECM', url: redirectUrl });
const pathToLogin = this.getRouteDestinationForLogin();
this.router.navigate(['/' + pathToLogin]);
if (!this.authService.isOauth() || this.isOAuthWithoutSilentLogin()) {
this.authService.setRedirect({ provider: 'ECM', url: redirectUrl });
const pathToLogin = this.getRouteDestinationForLogin();
this.router.navigate(['/' + pathToLogin]);
}
return false;
}
isOAuthWithoutSilentLogin() {
let oauth: OauthConfigModel = this.appConfig.get<OauthConfigModel>(AppConfigValues.OAUTHCONFIG, null);
return this.authService.isOauth() && oauth.silentLogin === false;
}
private getRouteDestinationForLogin(): string {
return this.appConfig &&
this.appConfig.get<string>('loginRoute') ?
this.appConfig.get<string>('loginRoute') : 'login';
this.appConfig.get<string>(AppConfigValues.LOGIN_ROUTE) ?
this.appConfig.get<string>(AppConfigValues.LOGIN_ROUTE) : 'login';
}
}