[ADF-3162] Setting component - Should be able to render the providers passed as input (#3464)

* Be able to change the available providers values

* Add deprecated tag

* add default providers

* Fix empty OAuth and selected providers
Improve the documentation

* Fix BPM guard to check SSO condition

* Add the oauthConfig again

* SSO or Basic otpion auth setting change

* fix host settings sso/basic
add login documentation

* remove test string

* fix auth guard test

* dispose upload emitter test events

* remove space

* exclude failing test
This commit is contained in:
Maurizio Vitale
2018-06-12 17:52:36 +01:00
committed by Eugenio Romano
parent 9221d1d0d0
commit 476b5864bf
22 changed files with 413 additions and 470 deletions

View File

@@ -20,7 +20,6 @@ import {
ActivatedRouteSnapshot, CanActivate, RouterStateSnapshot, Router,
PRIMARY_OUTLET, UrlTree, UrlSegmentGroup, UrlSegment
} from '@angular/router';
import { AlfrescoApiService } from './alfresco-api.service';
import { AuthenticationService } from './authentication.service';
import { AppConfigService } from '../app-config/app-config.service';
@@ -28,42 +27,30 @@ import { AppConfigService } from '../app-config/app-config.service';
export class AuthGuardEcm implements CanActivate {
constructor(
private authService: AuthenticationService,
private apiService: AlfrescoApiService,
private router: Router,
private appConfig: AppConfigService) {
}
private get authApi() {
return this.apiService.getInstance().ecmAuth;
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean {
return this.checkLogin(state.url);
}
private isLoggedIn(): Promise<boolean> {
if (this.authApi === undefined || !this.authApi.isLoggedIn()) {
return Promise.resolve(false);
}
return this.authApi
.validateTicket()
.then(() => true, () => false)
.catch(() => false);
}
canActivateChild(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Promise<boolean> {
canActivateChild(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean {
return this.canActivate(route, state);
}
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Promise<boolean> {
return this.isLoggedIn().then(isLoggedIn => {
if (!isLoggedIn) {
const navigation = this.getNavigationCommands(state.url);
checkLogin(redirectUrl: string): boolean {
if (this.authService.isEcmLoggedIn()) {
return true;
}
this.authService.setRedirect({ provider: 'ECM', navigation });
const pathToLogin = this.getRouteDestinationForLogin();
this.router.navigate(['/' + pathToLogin]);
}
const navigation = this.getNavigationCommands(redirectUrl);
return isLoggedIn;
});
this.authService.setRedirect({ provider: 'ECM', navigation });
const pathToLogin = this.getRouteDestinationForLogin();
this.router.navigate(['/' + pathToLogin]);
return false;
}
private getRouteDestinationForLogin(): string {