85979: only show security tab on profile page when canChangePassword FeatureID is true

This commit is contained in:
lotte
2021-12-15 14:04:38 +01:00
parent df46bcd16f
commit 71e40fdb6e
3 changed files with 8 additions and 2 deletions

View File

@@ -13,6 +13,7 @@ export enum FeatureID {
CanManageGroup = 'canManageGroup', CanManageGroup = 'canManageGroup',
IsCollectionAdmin = 'isCollectionAdmin', IsCollectionAdmin = 'isCollectionAdmin',
IsCommunityAdmin = 'isCommunityAdmin', IsCommunityAdmin = 'isCommunityAdmin',
CanChangePassword = 'canChangePassword',
CanDownload = 'canDownload', CanDownload = 'canDownload',
CanRequestACopy = 'canRequestACopy', CanRequestACopy = 'canRequestACopy',
CanManageVersions = 'canManageVersions', CanManageVersions = 'canManageVersions',

View File

@@ -7,7 +7,7 @@
<ds-profile-page-metadata-form [user]="user"></ds-profile-page-metadata-form> <ds-profile-page-metadata-form [user]="user"></ds-profile-page-metadata-form>
</div> </div>
</div> </div>
<div class="card mb-4"> <div *ngIf="canChangePassword$ | async" class="card mb-4">
<div class="card-header">{{'profile.card.security' | translate}}</div> <div class="card-header">{{'profile.card.security' | translate}}</div>
<div class="card-body"> <div class="card-body">
<ds-profile-page-security-form <ds-profile-page-security-form

View File

@@ -18,6 +18,8 @@ import { hasValue, isNotEmpty } from '../shared/empty.util';
import { followLink } from '../shared/utils/follow-link-config.model'; import { followLink } from '../shared/utils/follow-link-config.model';
import { AuthService } from '../core/auth/auth.service'; import { AuthService } from '../core/auth/auth.service';
import { Operation } from 'fast-json-patch'; import { Operation } from 'fast-json-patch';
import { AuthorizationDataService } from '../core/data/feature-authorization/authorization-data.service';
import { FeatureID } from '../core/data/feature-authorization/feature-id';
@Component({ @Component({
selector: 'ds-profile-page', selector: 'ds-profile-page',
@@ -67,11 +69,13 @@ export class ProfilePageComponent implements OnInit {
* The authenticated user * The authenticated user
*/ */
private currentUser: EPerson; private currentUser: EPerson;
canChangePassword$: Observable<boolean>;
constructor(private authService: AuthService, constructor(private authService: AuthService,
private notificationsService: NotificationsService, private notificationsService: NotificationsService,
private translate: TranslateService, private translate: TranslateService,
private epersonService: EPersonDataService) { private epersonService: EPersonDataService,
private authorizationService: AuthorizationDataService) {
} }
ngOnInit(): void { ngOnInit(): void {
@@ -83,6 +87,7 @@ export class ProfilePageComponent implements OnInit {
tap((user: EPerson) => this.currentUser = user) tap((user: EPerson) => this.currentUser = user)
); );
this.groupsRD$ = this.user$.pipe(switchMap((user: EPerson) => user.groups)); this.groupsRD$ = this.user$.pipe(switchMap((user: EPerson) => user.groups));
this.canChangePassword$ = this.user$.pipe(switchMap((user:EPerson) => this.authorizationService.isAuthorized(FeatureID.CanChangePassword, user._links.self.href)));
} }
/** /**