mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
Use hash strategy in demo shell as the other apps (#6402)
* hash startegy * use hash in e2e * trigger build * fix * fix * remove children router overwrite crazynes * Update login.module.ts * revert not needed changes * some fixes * fix * remove fdescribe * fix * fix * Update share-file.e2e.ts * Update lock-file.e2e.ts * Update share-file.e2e.ts * some fix * some other fixes * username as id * fix after rebase * username * fix usernamee * Fix the errorComponent * Attempt to fix unit test - to check * * Fixed circular dependency error while building adf-testing package * * Fixed failing UT * fix * use username * some fixes * some fix * fix Co-authored-by: Maurizio Vitale <maurizio.vitale@alfresco.com> Co-authored-by: Vito Albano <vitoalbano@vitoalbano-mbp-0120.local> Co-authored-by: sivakumar414ram <siva.kumar@muraai.com>
This commit is contained in:
@@ -21,11 +21,11 @@ import {
|
||||
} from '@angular/core';
|
||||
import { AbstractControl, FormBuilder, FormGroup, Validators } from '@angular/forms';
|
||||
import { Router, ActivatedRoute, Params } from '@angular/router';
|
||||
import { Location } from '@angular/common';
|
||||
import { AuthenticationService } from '../../services/authentication.service';
|
||||
import { LogService } from '../../services/log.service';
|
||||
import { TranslationService } from '../../services/translation.service';
|
||||
import { UserPreferencesService } from '../../services/user-preferences.service';
|
||||
import { AlfrescoApiService } from '../../services/alfresco-api.service';
|
||||
|
||||
import { LoginErrorEvent } from '../models/login-error.event';
|
||||
import { LoginSubmitEvent } from '../models/login-submit.event';
|
||||
@@ -139,10 +139,11 @@ export class LoginComponent implements OnInit, OnDestroy {
|
||||
private router: Router,
|
||||
private appConfig: AppConfigService,
|
||||
private userPreferences: UserPreferencesService,
|
||||
private location: Location,
|
||||
private route: ActivatedRoute,
|
||||
private sanitizer: DomSanitizer
|
||||
) {}
|
||||
private sanitizer: DomSanitizer,
|
||||
private alfrescoApiService: AlfrescoApiService
|
||||
) {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.initFormError();
|
||||
@@ -154,10 +155,14 @@ export class LoginComponent implements OnInit, OnDestroy {
|
||||
if (oauth && oauth.implicitFlow) {
|
||||
this.implicitFlow = true;
|
||||
}
|
||||
|
||||
if (oauth && oauth.silentLogin && !this.authService.isLoggedIn()) {
|
||||
this.alfrescoApiService.getInstance().oauth2Auth.implicitLogin();
|
||||
}
|
||||
}
|
||||
|
||||
if (this.authService.isEcmLoggedIn() || this.authService.isBpmLoggedIn()) {
|
||||
this.location.forward();
|
||||
if (this.authService.isLoggedIn()) {
|
||||
this.router.navigate([this.successRoute]);
|
||||
} else {
|
||||
this.route.queryParams.subscribe((params: Params) => {
|
||||
const url = params['redirectUrl'];
|
||||
@@ -204,6 +209,9 @@ export class LoginComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
implicitLogin() {
|
||||
if (this.authService.isLoggedIn()) {
|
||||
this.router.navigate([this.successRoute]);
|
||||
}
|
||||
this.authService.ssoImplicitLogin();
|
||||
}
|
||||
|
||||
|
@@ -65,10 +65,6 @@ export abstract class AuthGuardBase implements CanActivate, CanActivateChild {
|
||||
if (this.authenticationService.isEcmLoggedIn() || this.withCredentials) {
|
||||
if (redirectFragment) {
|
||||
this.storageService.removeItem('loginFragment');
|
||||
const routeRedirectTo = route.routeConfig.children.filter( (routeTo) => routeTo.path === '' );
|
||||
if (routeRedirectTo?.length > 0) {
|
||||
routeRedirectTo[0].redirectTo = redirectFragment;
|
||||
}
|
||||
return this.router.createUrlTree([redirectFragment]);
|
||||
}
|
||||
return true;
|
||||
@@ -91,16 +87,18 @@ export abstract class AuthGuardBase implements CanActivate, CanActivateChild {
|
||||
}
|
||||
|
||||
protected redirectToUrl(provider: string, url: string) {
|
||||
if (!this.isSilentLogin()) {
|
||||
const pathToLogin = `/${this.getLoginRoute()}`;
|
||||
let urlToRedirect;
|
||||
if (!this.authenticationService.isOauth()) {
|
||||
this.authenticationService.setRedirect({ provider, url });
|
||||
|
||||
const pathToLogin = this.getLoginRoute();
|
||||
const urlToRedirect = `/${pathToLogin}?redirectUrl=${url}`;
|
||||
|
||||
this.dialog.closeAll();
|
||||
|
||||
this.router.navigateByUrl(urlToRedirect);
|
||||
urlToRedirect = `${pathToLogin}?redirectUrl=${url}`;
|
||||
} else {
|
||||
urlToRedirect = pathToLogin;
|
||||
}
|
||||
|
||||
this.dialog.closeAll();
|
||||
this.router.navigateByUrl(urlToRedirect);
|
||||
}
|
||||
|
||||
protected getLoginRoute(): string {
|
||||
@@ -131,4 +129,5 @@ export abstract class AuthGuardBase implements CanActivate, CanActivateChild {
|
||||
|
||||
return this.authenticationService.isOauth() && oauth && oauth.silentLogin;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -97,7 +97,7 @@ describe('AuthGuardService ECM', () => {
|
||||
expect(router.navigateByUrl).toHaveBeenCalled();
|
||||
}));
|
||||
|
||||
it('should not redirect url if the alfresco js api is NOT logged in and isOAuth with silentLogin', async(() => {
|
||||
it('should redirect url if the alfresco js api is NOT logged in and isOAuth with silentLogin', async(() => {
|
||||
spyOn(router, 'navigateByUrl').and.stub();
|
||||
spyOn(authService, 'isEcmLoggedIn').and.returnValue(false);
|
||||
spyOn(authService, 'isOauth').and.returnValue(true);
|
||||
@@ -116,7 +116,7 @@ describe('AuthGuardService ECM', () => {
|
||||
const route: RouterStateSnapshot = <RouterStateSnapshot> {url : 'abc'};
|
||||
|
||||
expect(authGuard.canActivate(null, route)).toBeTruthy();
|
||||
expect(router.navigateByUrl).toHaveBeenCalledTimes(0);
|
||||
expect(router.navigateByUrl).toHaveBeenCalledTimes(1);
|
||||
expect(authService.ssoImplicitLogin).toHaveBeenCalledTimes(1);
|
||||
}));
|
||||
|
||||
|
@@ -103,7 +103,7 @@ describe('AuthGuardService', () => {
|
||||
appConfigService.config.oauth2.silentLogin = true;
|
||||
|
||||
expect(await authGuard.canActivate(null, state)).toBeFalsy();
|
||||
expect(router.navigateByUrl).not.toHaveBeenCalled();
|
||||
expect(router.navigateByUrl).toHaveBeenCalled();
|
||||
}));
|
||||
|
||||
it('should set redirect url', async(async () => {
|
||||
|
@@ -1,13 +1,13 @@
|
||||
<div class="adf-error-content">
|
||||
<p class="adf-error-content-code">
|
||||
{{ errorCode }}
|
||||
{{ errorCodeTranslated }}
|
||||
</p>
|
||||
<div class="adf-error-content-shadow"></div>
|
||||
<p class="adf-error-content-title">
|
||||
{{ 'ERROR_CONTENT.' + errorCode + '.TITLE' | translate }}
|
||||
{{ 'ERROR_CONTENT.' + errorCodeTranslated + '.TITLE' | translate }}
|
||||
</p>
|
||||
<p class="adf-error-content-description">
|
||||
{{ 'ERROR_CONTENT.' + errorCode + '.DESCRIPTION' | translate }}
|
||||
{{ 'ERROR_CONTENT.' + errorCodeTranslated + '.DESCRIPTION' | translate }}
|
||||
</p>
|
||||
<ng-content select="[adf-error-content-actions]"></ng-content>
|
||||
</div>
|
||||
|
@@ -123,7 +123,7 @@ describe('ErrorContentComponent', () => {
|
||||
spyOn(translateService, 'instant').and.returnValue(of('404'));
|
||||
fixture.detectChanges();
|
||||
fixture.whenStable().then(() => {
|
||||
expect(errorContentComponent.errorCode).toBe('404');
|
||||
expect(errorContentComponent.errorCodeTranslated).toBe('404');
|
||||
});
|
||||
}));
|
||||
});
|
||||
|
@@ -22,9 +22,8 @@ import {
|
||||
ViewEncapsulation,
|
||||
OnInit
|
||||
} from '@angular/core';
|
||||
import { Params, ActivatedRoute } from '@angular/router';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
import { TranslationService } from '../../services/translation.service';
|
||||
|
||||
@Component({
|
||||
selector: 'adf-error-content',
|
||||
templateUrl: './error-content.component.html',
|
||||
@@ -41,16 +40,18 @@ export class ErrorContentComponent implements OnInit {
|
||||
@Input()
|
||||
errorCode: string = ErrorContentComponent.UNKNOWN_ERROR;
|
||||
|
||||
errorCodeTranslated: string;
|
||||
|
||||
constructor(private route: ActivatedRoute,
|
||||
private translateService: TranslationService) {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
if (this.route) {
|
||||
this.route.params.forEach((params: Params) => {
|
||||
if (params['id']) {
|
||||
this.errorCode = this.checkErrorExists(params['id']) ? params['id'] : ErrorContentComponent.UNKNOWN_ERROR;
|
||||
}
|
||||
this.route.params.subscribe(params => {
|
||||
const code = params['id'] || this.errorCode;
|
||||
const errorHasTranslation = this.checkErrorExists(code);
|
||||
this.errorCodeTranslated = errorHasTranslation ? code : ErrorContentComponent.UNKNOWN_ERROR;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user