[AAE-12501] Get username with authentication service

This commit is contained in:
Amedeo Lepore
2023-03-31 12:12:03 +02:00
parent 7db91b47af
commit 86d502314a
2 changed files with 4 additions and 4 deletions
@@ -87,7 +87,7 @@ export class ContentService {
*/
hasPermissions(node: Node, permission: PermissionsEnum | string, userId?: string): boolean {
let hasPermissions = false;
userId = userId ?? this.apiService.getInstance().getEcmUsername();
userId = userId ?? this.authService.getEcmUsername();
const permissions = [...(node.permissions?.locallySet || []), ...(node.permissions?.inherited || [])]
.filter((currentPermission) => currentPermission.authorityId === userId);
@@ -17,7 +17,7 @@
import { Injectable } from '@angular/core';
import { Node } from '@alfresco/js-api';
import { AlfrescoApiService } from '@alfresco/adf-core';
import { AuthenticationService } from '@alfresco/adf-core';
import moment, { Moment } from 'moment';
@Injectable({
@@ -25,7 +25,7 @@ import moment, { Moment } from 'moment';
})
export class LockService {
constructor(private alfrescoApiService: AlfrescoApiService) {
constructor(private authService: AuthenticationService) {
}
isLocked(node: Node): boolean {
@@ -34,7 +34,7 @@ export class LockService {
if (this.isReadOnlyLock(node)) {
isLocked = !this.isLockExpired(node);
} else if (this.isLockOwnerAllowed(node)) {
isLocked = this.alfrescoApiService.getInstance().getEcmUsername() !== node.properties['cm:lockOwner'].id;
isLocked = this.authService.getEcmUsername() !== node.properties['cm:lockOwner'].id;
if (this.isLockExpired(node)) {
isLocked = false;
}