Fix role verification for community members. Modify isPrivate in communityHelper to include membership.

This commit is contained in:
Konstantinos Triantafyllou 2023-10-10 22:40:01 +03:00
parent c29488545e
commit ff4411d695
2 changed files with 20 additions and 10 deletions

View File

@ -1,6 +1,7 @@
import {HttpParams} from '@angular/common/http';
import {properties} from "../../../environments/environment";
import {Session} from "../login/utils/helper.class";
import {CommunityInfo} from "./community/communityInfo";
export class ConnectHelper {
@ -53,7 +54,12 @@ export class ConnectHelper {
}
public static isPrivate(community, user) {
return community && (community.isPrivate() || (community.isRestricted() && !(Session.isPortalAdministrator(user) || Session.isCommunityCurator(user) || Session.isManager("community", community.communityId, user))))
public static isPrivate(community: CommunityInfo, user) {
return community && (community.isPrivate() || (community.isRestricted() && !(
Session.isPortalAdministrator(user) ||
Session.isCommunityCurator(user) ||
Session.isManager("community", community.communityId, user) ||
(!community.isOpen() && Session.isMember('community', community.communityId, user))
)))
}
}

View File

@ -34,7 +34,7 @@ import {ClearCacheService} from "../services/clear-cache.service";
<loading></loading>
</div>
</modal-alert>
<modal-alert #memberModal [overflowBody]="false" *ngIf="service == 'monitor'" (cancelOutput)="cancel()"
<modal-alert #memberModal [overflowBody]="false" (cancelOutput)="cancel()"
(alertOutput)="verifyMember()" [okDisabled]="(code.invalid || loading) && !isMember">
<div *ngIf="!isMember">
<div>
@ -119,12 +119,8 @@ export class RoleVerificationComponent implements OnInit, OnDestroy, AfterViewIn
ngAfterViewInit() {
this.subscriptions.push(this.userManagementService.getUserInfo().subscribe(user => {
this.user = user;
if (this.paramsSubscription instanceof Subscription) {
this.paramsSubscription.unsubscribe();
}
this.paramsSubscription = this.route.queryParams.subscribe(params => {
if (params) {
this.isMember = !!params['isMember'];
this.cdr.detectChanges();
if(params['verify'] && !this.isMember) {
if (this.user) {
@ -133,7 +129,7 @@ export class RoleVerificationComponent implements OnInit, OnDestroy, AfterViewIn
if (this.user.email === this.verification.email.toLowerCase() && this.id === this.verification.entity && this.type === this.verification.type) {
if (this.verification.verificationType === 'manager') {
this.openManagerModal();
} else if (this.verification.verificationType === 'member' && this.service === "monitor") {
} else if (this.verification.verificationType === 'member') {
this.openMemberModal();
} else {
this.openErrorModal();
@ -217,6 +213,9 @@ export class RoleVerificationComponent implements OnInit, OnDestroy, AfterViewIn
this.managerModal.cancel();
this.error = null;
this.userManagementService.updateUserInfo(() => {
if (this.paramsSubscription instanceof Subscription) {
this.paramsSubscription.unsubscribe();
}
if (this.service === "monitor") {
this.loading = false;
this.router.navigate(['/admin/' + this.verification.entity]);
@ -254,8 +253,12 @@ export class RoleVerificationComponent implements OnInit, OnDestroy, AfterViewIn
this.clearCacheService.clearCache('Members updated');
this.loading = false;
this.error = null;
this.isMember = true;
this.userManagementService.updateUserInfo(() => {
this.router.navigate([], {queryParams: {'verify': null, 'isMember': true}});
if (this.paramsSubscription instanceof Subscription) {
this.paramsSubscription.unsubscribe();
}
this.cancel();
});
}, error => {
this.loading = false;
@ -271,6 +274,7 @@ export class RoleVerificationComponent implements OnInit, OnDestroy, AfterViewIn
}
cancel() {
this.router.navigate([], {queryParams: {'verify': null, 'isMember': null}});
this.isMember = false;
this.router.navigate([]);
}
}