diff --git a/login/user.component.ts b/login/user.component.ts index f95adf67..08497f70 100644 --- a/login/user.component.ts +++ b/login/user.component.ts @@ -27,7 +27,6 @@ export class UserComponent { public errorCode: string = ""; public redirectUrl: string = ""; public routerHelper: RouterHelper = new RouterHelper(); - public loginUrl; public properties: EnvProperties = properties; @Input() mainComponent = true; @@ -40,7 +39,6 @@ export class UserComponent { } ngOnInit() { - this.loginUrl = this.properties.loginUrl; if (typeof document !== 'undefined') { this.server = false; this.userManagementsService.updateUserInfo( () => { diff --git a/role-verification/role-verification.component.ts b/role-verification/role-verification.component.ts index 29d993dc..416c2624 100644 --- a/role-verification/role-verification.component.ts +++ b/role-verification/role-verification.component.ts @@ -1,10 +1,10 @@ -import {AfterViewInit, ChangeDetectorRef, Component, Input, OnDestroy, OnInit, ViewChild} from "@angular/core"; +import {AfterViewInit, ChangeDetectorRef, Component, Input, OnInit, ViewChild} from "@angular/core"; import {Role, User} from "../login/utils/helper.class"; import {ActivatedRoute, Router} from "@angular/router"; import {UserManagementService} from "../services/user-management.service"; import {UserRegistryService} from "../services/user-registry.service"; import {LoginErrorCodes} from "../login/utils/guardHelper.class"; -import {Subscriber, Subscription} from "rxjs"; +import {Subscription} from "rxjs"; import {UntypedFormBuilder, UntypedFormControl, Validators} from "@angular/forms"; import {AlertModal} from "../utils/modal/alert"; import {properties} from "../../../environments/environment"; @@ -88,7 +88,7 @@ export class RoleVerificationComponent extends BaseComponent implements OnInit, @Input() public name: string; @Input() - public service: "connect" | "monitor" = "monitor"; + public service: "connect" | "monitor" | "irish" = "monitor"; @Input() public userInfoLinkPrefix = ''; @Input() @@ -216,7 +216,10 @@ export class RoleVerificationComponent extends BaseComponent implements OnInit, if (this.paramsSubscription instanceof Subscription) { this.paramsSubscription.unsubscribe(); } - if (this.service === "monitor" ) { + if(this.service === "irish") { + this.loading = false; + this.userManagementService.login(properties.domain + '/admin/' + this.verification.entity); + } else if (this.service === "monitor" ) { this.loading = false; this._router.navigate(['/admin/' + this.verification.entity]); } else { diff --git a/services/user-management.service.ts b/services/user-management.service.ts index 3b0a9d3f..29997a60 100644 --- a/services/user-management.service.ts +++ b/services/user-management.service.ts @@ -7,6 +7,7 @@ import {properties} from "../../../environments/environment"; import {StringUtils} from "../utils/string-utils.class"; import {CustomOptions} from "./servicesUtils/customOptions.class"; import {AdvancedAsyncSubject} from "../utils/AdvancedAsyncSubject"; +import {isArray} from "rxjs/internal-compatibility"; @Injectable({ providedIn: 'root' @@ -80,18 +81,36 @@ export class UserManagementService { } } - public login() { - if (this.fixRedirectURL) { + public login(redirect: string = null) { + if(redirect) { + this.redirectUrl = redirect; + } else if (this.fixRedirectURL) { this.setRedirectUrl(this.fixRedirectURL); } else { this.setRedirectUrl(); } - window.location.href = properties.loginUrl + "?redirect=" + this.redirectUrl; + window.location.href = this.setURL(properties.loginUrl) + encodeURIComponent(this.redirectUrl); } public logout() { this.setRedirectUrl(); Session.removeUser(); - window.location.href = properties.logoutUrl + "?redirect=" + this.redirectUrl; + window.location.href = this.setURL(properties.logoutUrl) + encodeURIComponent(this.redirectUrl); + } + + setURL(url: string | string[]) { + if(isArray(url)) { + let redirectURL = ''; + url.forEach((url, index) => { + if(index === 0) { + redirectURL = url + "?redirect="; + } else { + redirectURL += encodeURIComponent(url + "?redirect="); + } + }); + return redirectURL; + } else { + return url + "?redirect="; + } } } diff --git a/utils/properties/env-properties.ts b/utils/properties/env-properties.ts index 13f9aec2..8d9278aa 100644 --- a/utils/properties/env-properties.ts +++ b/utils/properties/env-properties.ts @@ -57,9 +57,9 @@ export interface EnvProperties { vocabulariesAPI?: string; piwikBaseUrl?: string; piwikSiteId?: string; - loginUrl?: string; + loginUrl?: string | string[]; registryUrl?: string; - logoutUrl?: string; + logoutUrl?: string | string[]; userInfoUrl?: string; developersApiUrl?: string, cookieDomain?: string;