mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-4183] improved auth redirection (#4399)
* base auth guard implementation * remove code duplication * unit test fixes
This commit is contained in:
committed by
Eugenio Romano
parent
bf331f1145
commit
f6341e31a0
@@ -20,8 +20,8 @@ import {
|
||||
Input, OnInit, Output, TemplateRef, ViewEncapsulation
|
||||
} from '@angular/core';
|
||||
import { AbstractControl, FormBuilder, FormGroup, Validators } from '@angular/forms';
|
||||
import { Router } from '@angular/router';
|
||||
|
||||
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';
|
||||
@@ -140,7 +140,9 @@ export class LoginComponent implements OnInit {
|
||||
private logService: LogService,
|
||||
private router: Router,
|
||||
private appConfig: AppConfigService,
|
||||
private userPreferences: UserPreferencesService
|
||||
private userPreferences: UserPreferencesService,
|
||||
private location: Location,
|
||||
private route: ActivatedRoute
|
||||
) {
|
||||
this.initFormError();
|
||||
this.initFormFieldsMessages();
|
||||
@@ -154,6 +156,17 @@ export class LoginComponent implements OnInit {
|
||||
}
|
||||
}
|
||||
|
||||
if (this.authService.isEcmLoggedIn() || this.authService.isBpmLoggedIn()) {
|
||||
this.location.forward();
|
||||
} else {
|
||||
this.route.queryParams.subscribe((params: Params) => {
|
||||
const url = params['redirectUrl'];
|
||||
const provider = this.appConfig.get<string>(AppConfigValues.PROVIDERS);
|
||||
|
||||
this.authService.setRedirect({ provider, url });
|
||||
});
|
||||
}
|
||||
|
||||
if (this.hasCustomFieldsValidation()) {
|
||||
this.form = this._fb.group(this.fieldsValidation);
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user