[angular-16-irish-monitor]: LoginURL property now suppors mutible URLs.

This commit is contained in:
Konstantinos Triantafyllou 2023-12-18 17:35:36 +02:00
parent 52d63ece25
commit 48ce09e400
4 changed files with 32 additions and 12 deletions

View File

@ -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( () => {

View File

@ -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 {

View File

@ -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=";
}
}
}

View File

@ -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;