[angular-16-irish-monitor | CHANGED | DONE]: Remove loginURL, logoutURL and userInfoURL properties and add loginServiceURL.

This commit is contained in:
Konstantinos Triantafyllou 2024-01-07 01:41:59 +02:00
parent 367bdc3092
commit bc4e30c3f2
9 changed files with 29 additions and 38 deletions

View File

@ -37,7 +37,6 @@ export class ClaimsAdminComponent {
@Input() isConnect: boolean = false; @Input() isConnect: boolean = false;
@Input() externalPortalUrl: string; @Input() externalPortalUrl: string;
@Input() claimsInfoURL: string; @Input() claimsInfoURL: string;
@Input() userInfoURL: string;
public user: User = null; public user: User = null;
sub; sub;

View File

@ -30,7 +30,6 @@ import {Subscriber} from "rxjs";
export class MyClaimsComponent { export class MyClaimsComponent {
@Input() claimsInfoURL: string; @Input() claimsInfoURL: string;
@Input() communityId:string; @Input() communityId:string;
@Input() userInfoURL: string;
public user: User = null; public user: User = null;
constructor(private userManagementService: UserManagementService, private _router: Router) {} constructor(private userManagementService: UserManagementService, private _router: Router) {}

View File

@ -11,7 +11,7 @@ import * as url from "url";
@Injectable() @Injectable()
export class ErrorInterceptorService implements HttpInterceptor { export class ErrorInterceptorService implements HttpInterceptor {
private static UNAUTHORIZED_WHITELIST = [properties.userInfoUrl, properties.orcidAPIURL, properties.registryUrl? (properties.registryUrl + 'verification/'):null, properties.eoscDataTransferAPI].filter(value => !!value); private static UNAUTHORIZED_WHITELIST = [properties.orcidAPIURL, properties.registryUrl? (properties.registryUrl + 'verification/'):null, properties.eoscDataTransferAPI].filter(value => !!value);
private url: string = null; private url: string = null;
constructor(private router: Router) { constructor(private router: Router) {

View File

@ -122,12 +122,8 @@ export class UserMiniComponent implements OnInit, OnChanges {
public isAuthorized: boolean = false; public isAuthorized: boolean = false;
@Input() public mobileView: boolean = false; @Input() public mobileView: boolean = false;
public firstLetters: string = ""; public firstLetters: string = "";
public server: boolean = true;
public routerHelper: RouterHelper = new RouterHelper(); public routerHelper: RouterHelper = new RouterHelper();
@Input() userMenuItems; @Input() userMenuItems;
@Input() logInUrl;
@Input() logOutUrl;
@Input() cookieDomain;
@Input() notificationConfiguration: NotificationConfiguration; @Input() notificationConfiguration: NotificationConfiguration;
@ViewChild('notificationsSidebar') notificationsSidebar: NotificationsSidebarComponent; @ViewChild('notificationsSidebar') notificationsSidebar: NotificationsSidebarComponent;
public showNotifications = false; public showNotifications = false;
@ -137,9 +133,6 @@ export class UserMiniComponent implements OnInit, OnChanges {
} }
ngOnInit() { ngOnInit() {
if (typeof document !== 'undefined') {
this.server = false;
}
this.initUser(); this.initUser();
} }

View File

@ -42,7 +42,7 @@ export class User {
this.role = []; this.role = [];
if (info.roles) { if (info.roles) {
info.roles.forEach(role => { info.roles.forEach(role => {
this.role.push(role); this.role.push(decodeURIComponent(role).replace('$$', '::'));
}); });
} else { } else {
if (info.edu_person_entitlements) { if (info.edu_person_entitlements) {

View File

@ -14,6 +14,9 @@ import {isArray} from "rxjs/internal-compatibility";
}) })
export class UserManagementService { export class UserManagementService {
private readonly getUserInfoSubject: AdvancedAsyncSubject<User> = new AdvancedAsyncSubject<User>(); private readonly getUserInfoSubject: AdvancedAsyncSubject<User> = new AdvancedAsyncSubject<User>();
private static LOGIN = 'openid_connect_login';
private static LOGOUT: string = 'openid_logout';
private static USERINFO: string = 'userInfo';
public fixRedirectURL: string = null; public fixRedirectURL: string = null;
private redirectUrl: string = null; private redirectUrl: string = null;
private subscription; private subscription;
@ -40,10 +43,17 @@ export class UserManagementService {
return this.getUserInfoSubject.asObservable(); return this.getUserInfoSubject.asObservable();
} }
public updateUserInfo(resolve: Function = null) { public getUserInfoAt(index = 1): Observable<User> {
this.subscription = this.http.get<User>(properties.userInfoUrl, CustomOptions.registryOptions()).pipe(map(userInfo => { return this.http.get<User>((isArray(properties.loginServiceURL)?properties.loginServiceURL[index]:properties.loginServiceURL) +
UserManagementService.USERINFO, CustomOptions.registryOptions()).pipe(map(userInfo => {
return new User(userInfo); return new User(userInfo);
})).subscribe(user => { }))
}
public updateUserInfo(resolve: Function = null) {
this.subscription = this.getUserInfoAt().subscribe(user => {
console.log(user)
this.getUserInfoSubject.next(user); this.getUserInfoSubject.next(user);
if (resolve) { if (resolve) {
resolve(); resolve();
@ -85,20 +95,24 @@ export class UserManagementService {
if(redirect) { if(redirect) {
this.redirectUrl = redirect; this.redirectUrl = redirect;
} else if (this.fixRedirectURL) { } else if (this.fixRedirectURL) {
console.log(this.fixRedirectURL)
this.setRedirectUrl(this.fixRedirectURL); this.setRedirectUrl(this.fixRedirectURL);
} else { } else {
this.setRedirectUrl(); this.setRedirectUrl();
} }
window.location.href = this.setURL(properties.loginUrl) + encodeURIComponent(this.redirectUrl); let loginURL: string | string[] = isArray(properties.loginServiceURL)?properties.loginServiceURL.map(url => url + UserManagementService.LOGIN):(properties.loginServiceURL + UserManagementService.LOGIN);
window.location.href = this.setURL(loginURL) + this.redirectUrl;
} }
public logout() { public logout() {
this.setRedirectUrl(); this.setRedirectUrl();
Session.removeUser(); Session.removeUser();
window.location.href = this.setURL(properties.logoutUrl) + encodeURIComponent(this.redirectUrl); let logoutURL: string | string[] = isArray(properties.loginServiceURL)?properties.loginServiceURL.map(url => url + UserManagementService.LOGOUT):(properties.loginServiceURL + UserManagementService.LOGOUT);
window.location.href = this.setURL(logoutURL) + this.redirectUrl;
} }
setURL(url: string | string[]) { setURL(url: string | string[]) {
console.log(url);
if(isArray(url)) { if(isArray(url)) {
let redirectURL = ''; let redirectURL = '';
url.forEach((url, index) => { url.forEach((url, index) => {

View File

@ -12,9 +12,7 @@
</div> </div>
<div *ngIf="!onlyTop || userMenu" class="uk-navbar-right" [class.uk-light]='activeHeader.darkBg'> <div *ngIf="!onlyTop || userMenu" class="uk-navbar-right" [class.uk-light]='activeHeader.darkBg'>
<ng-container *ngIf="userMenu"> <ng-container *ngIf="userMenu">
<user-mini [user]="user" mobileView=true <user-mini [user]="user" mobileView=true [userMenuItems]=userMenuItems [notificationConfiguration]="notificationConfiguration"></user-mini>
[userMenuItems]=userMenuItems [logInUrl]=properties.loginUrl [notificationConfiguration]="notificationConfiguration"
[logOutUrl]=properties.logoutUrl [cookieDomain]=properties.cookieDomain></user-mini>
</ng-container> </ng-container>
</div> </div>
</nav> </nav>
@ -192,9 +190,7 @@
</div> </div>
</div> </div>
<user-mini *ngIf="!searchMode && userMenu" [user]="user" <user-mini *ngIf="!searchMode && userMenu" [user]="user" [userMenuItems]=userMenuItems></user-mini>
[userMenuItems]=userMenuItems [logInUrl]=properties.loginUrl [logOutUrl]=properties.logoutUrl
[cookieDomain]=properties.cookieDomain></user-mini>
<div class="uk-visible@m"> <div class="uk-visible@m">
<ng-content select="[extra-m]"></ng-content> <ng-content select="[extra-m]"></ng-content>
</div> </div>

View File

@ -57,10 +57,8 @@ export interface EnvProperties {
vocabulariesAPI?: string; vocabulariesAPI?: string;
piwikBaseUrl?: string; piwikBaseUrl?: string;
piwikSiteId?: string; piwikSiteId?: string;
loginUrl?: string | string[]; loginServiceURL?: string | string[];
registryUrl?: string; registryUrl?: string;
logoutUrl?: string | string[];
userInfoUrl?: string;
developersApiUrl?: string, developersApiUrl?: string,
cookieDomain?: string; cookieDomain?: string;
feedbackmail?: string; feedbackmail?: string;

View File

@ -107,9 +107,7 @@ export let commonDev: EnvProperties = {
orcidClientId: "APP-A5M3KTX6NCN67L91", orcidClientId: "APP-A5M3KTX6NCN67L91",
utilsService: "http://mpagasas.di.uoa.gr:8000", utilsService: "http://mpagasas.di.uoa.gr:8000",
vocabulariesAPI: "https://dev-openaire.d4science.org/provision/mvc/vocabularies/", vocabulariesAPI: "https://dev-openaire.d4science.org/provision/mvc/vocabularies/",
loginUrl: "http://mpagasas.di.uoa.gr:19080/login-service/openid_connect_login", loginServiceURL: "http://mpagasas.di.uoa.gr:19080/login-service/",
userInfoUrl: "http://mpagasas.di.uoa.gr:19080/login-service/userInfo",
logoutUrl: "http://mpagasas.di.uoa.gr:19080/login-service/openid_logout",
cookieDomain: ".di.uoa.gr", cookieDomain: ".di.uoa.gr",
feedbackmail: "kostis30fylloy@gmail.com", feedbackmail: "kostis30fylloy@gmail.com",
cacheUrl: "http://dl170.madgik.di.uoa.gr:3000/get?url=", cacheUrl: "http://dl170.madgik.di.uoa.gr:3000/get?url=",
@ -146,9 +144,7 @@ export let commonTest: EnvProperties = {
csvAPIURL: "https://services.openaire.eu/search/v2/api/reports", csvAPIURL: "https://services.openaire.eu/search/v2/api/reports",
utilsService: "https://explore.openaire.eu/utils-service", utilsService: "https://explore.openaire.eu/utils-service",
vocabulariesAPI: "https://services.openaire.eu/provision/mvc/vocabularies/", vocabulariesAPI: "https://services.openaire.eu/provision/mvc/vocabularies/",
loginUrl: " https://services.openaire.eu/login-service/openid_connect_login", loginServiceURL: " https://services.openaire.eu/login-service/",
userInfoUrl: " https://services.openaire.eu/login-service/userInfo",
logoutUrl: "https://services.openaire.eu/login-service/openid_logout",
cacheUrl: "https://explore.openaire.eu/cache/get?url=", cacheUrl: "https://explore.openaire.eu/cache/get?url=",
datasourcesAPI: "https://services.openaire.eu/openaire/ds/api/", datasourcesAPI: "https://services.openaire.eu/openaire/ds/api/",
monitorServiceAPIURL: "https://services.openaire.eu/uoa-monitor-service", monitorServiceAPIURL: "https://services.openaire.eu/uoa-monitor-service",
@ -177,9 +173,7 @@ export let commonBeta: EnvProperties = {
csvAPIURL: "https://beta.services.openaire.eu/search/v2/api/reports", csvAPIURL: "https://beta.services.openaire.eu/search/v2/api/reports",
utilsService: "https://demo.openaire.eu/utils-service", utilsService: "https://demo.openaire.eu/utils-service",
vocabulariesAPI: "https://beta.services.openaire.eu/provision/mvc/vocabularies/", vocabulariesAPI: "https://beta.services.openaire.eu/provision/mvc/vocabularies/",
loginUrl: "https://beta.services.openaire.eu/login-service/openid_connect_login", loginServiceURL: "https://beta.services.openaire.eu/login-service/",
userInfoUrl: "https://beta.services.openaire.eu/login-service/userInfo",
logoutUrl: "https://beta.services.openaire.eu/login-service/openid_logout",
cacheUrl: "https://demo.openaire.eu/cache/get?url=", cacheUrl: "https://demo.openaire.eu/cache/get?url=",
datasourcesAPI: "https://beta.services.openaire.eu/openaire/ds/api/", datasourcesAPI: "https://beta.services.openaire.eu/openaire/ds/api/",
monitorServiceAPIURL: "https://beta.services.openaire.eu/uoa-monitor-service", monitorServiceAPIURL: "https://beta.services.openaire.eu/uoa-monitor-service",
@ -218,9 +212,7 @@ export let commonProd: EnvProperties = {
csvAPIURL: "https://services.openaire.eu/search/v2/api/reports", csvAPIURL: "https://services.openaire.eu/search/v2/api/reports",
utilsService: "https://explore.openaire.eu/utils-service", utilsService: "https://explore.openaire.eu/utils-service",
vocabulariesAPI: "https://services.openaire.eu/provision/mvc/vocabularies/", vocabulariesAPI: "https://services.openaire.eu/provision/mvc/vocabularies/",
loginUrl: " https://services.openaire.eu/login-service/openid_connect_login", loginServiceURL: "https://services.openaire.eu/login-service/",
userInfoUrl: " https://services.openaire.eu/login-service/userInfo",
logoutUrl: "https://services.openaire.eu/login-service/openid_logout",
cacheUrl: "https://explore.openaire.eu/cache/get?url=", cacheUrl: "https://explore.openaire.eu/cache/get?url=",
datasourcesAPI: "https://services.openaire.eu/openaire/ds/api/", datasourcesAPI: "https://services.openaire.eu/openaire/ds/api/",
monitorServiceAPIURL: "https://services.openaire.eu/uoa-monitor-service", monitorServiceAPIURL: "https://services.openaire.eu/uoa-monitor-service",