[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

@@ -16,20 +16,14 @@
*/
import { Injectable } from '@angular/core';
import {
ActivatedRouteSnapshot, CanActivate, CanActivateChild, RouterStateSnapshot,
Router
} from '@angular/router';
import { AppConfigService } from '../app-config/app-config.service';
import { ActivatedRouteSnapshot, CanActivate, CanActivateChild, RouterStateSnapshot, Router } from '@angular/router';
import { AppConfigService, AppConfigValues } from '../app-config/app-config.service';
import { AuthenticationService } from './authentication.service';
import { UserPreferencesService } from './user-preferences.service';
import { OauthConfigModel } from '../models/oauth-config.model';
@Injectable()
export class AuthGuardBpm implements CanActivate, CanActivateChild {
constructor(private authService: AuthenticationService,
private router: Router,
private userPreference: UserPreferencesService,
private appConfig: AppConfigService) {}
constructor(private authService: AuthenticationService, private router: Router, private appConfig: AppConfigService) {}
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean {
return this.checkLogin(state.url);
@@ -44,7 +38,7 @@ export class AuthGuardBpm implements CanActivate, CanActivateChild {
return true;
}
if (!this.authService.isOauth() || this.isOAuthWithoutSilentLogin() ) {
if (!this.authService.isOauth() || this.isOAuthWithoutSilentLogin()) {
this.authService.setRedirect({ provider: 'BPM', url: redirectUrl });
const pathToLogin = this.getRouteDestinationForLogin();
this.router.navigate(['/' + pathToLogin]);
@@ -54,12 +48,11 @@ export class AuthGuardBpm implements CanActivate, CanActivateChild {
}
isOAuthWithoutSilentLogin() {
return this.authService.isOauth() && this.userPreference.oauthConfig.silentLogin === false;
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';
return this.appConfig && this.appConfig.get<string>(AppConfigValues.LOGIN_ROUTE) ? this.appConfig.get<string>(AppConfigValues.LOGIN_ROUTE) : 'login';
}
}