Get User Permissions

Does someone have an idea how to get result from cubaApp.getPermission()?
My code is as follow but this.permissionInfo is null or undefined.

private subject = new Subject<any>();
  private userInfo: UserInfo;
  private cubaApp: CubaApp;

  private permissionInfo: PermissionInfo[];

  constructor(private storageService: StorageService,
              private alertService: AlertService,
              private cubaIntegrationService: CubaIntegrationService) {
    this.cubaApp = cubaIntegrationService.getCubaApp();
    this.userInfo = this.storageService.getCurrentUser();
    this.loadUserInfo();
  }

  loadUserInfo(): void {
    this.cubaApp.getUserInfo()
    .then(value => {
      this.userInfo = value;
      this.storageService.setCurrentUser(value);
      this.subject.next({ userInfo: this.getCurrentUser() });
    })
    .catch(() => {
      this.alertService.error('Can\'t obtain UserInfo');
    });

    this.cubaApp.getPermissions()
      .then(value => {
        this.permissionInfo = value;
    })
    .catch(() => {
      this.alertService.error('Can\'t obtain PermissionInfo');
    });
  }

  isAnonymous(): boolean {
    return this.userInfo == null || this.userInfo.login === 'anonymous';
  }

  getCurrentUser(): UserInfo {
    return this.isAnonymous() ? null : this.userInfo;
  }

  onUserInfoChanged(): Observable<any> {
    return this.subject.asObservable();
  }

  getPermissionInfo(): PermissionInfo[] {
    return this.permissionInfo ? null : this.permissionInfo;
  }

Could you check if there are any explicitly specified permissions? Otherwise REST API returns an empty array.

So, if I am logged in as admin with default. Then there is an empty array. An if I make changes changes will be reflected in an filled array?

Is it normal to call this when getting userinfo or shall I use own service?

REST API returns compilation of permissions of all roles assigned to current user. If you change user (login/logout) or make any changes in roles you should load permissions again.

The reason was that the result from json never left the service. If I added the permissionInfo in storage service then I got the data out of the service.

Sorry, I don’t get your last question. Could you please clarify what the problem is? I guess you are talking about Angular services?

I have manged to solve the problem.
What I do miss is the actual name of entities, menu item and screen names. Is it possible to get these or are they in language files?

Here is an example of permissions returned by REST

[
  {
    "type": "SCREEN",
    "target": "sec$User.browse",
    "value": "ALLOW",
    "intValue": 1
  },
  {
    "type": "ENTITY_OP",
    "target": "sec$Filter:read",
    "value": "ALLOW",
    "intValue": 1
  },
  {
    "type": "ENTITY_ATTR",
    "target": "sec$SessionLogEntry:clientType",
    "value": "MODIFY",
    "intValue": 2
  },
  {
    "type": "SPECIFIC",
    "target": "cuba.restApi.enabled",
    "value": "ALLOW",
    "intValue": 1
  }
]

So we have screen id in SCREEN permissions and can parse entity name in ENTITY_OP and ENTITY_ATTR permissions.

Sure.

{
    "type": "SCREEN",
    "target": "sec$User.browse",
    "value": "ALLOW",
    "intValue": 1
  }

Is it any opportunity to get Entity Name or is this Entity Name in the language resource files.