Merge pull request #11589 from opf/bug/44767-anonymouse-user-has-nextcloud-access-token

[#44767] Anonymouse User has Nextcloud access token
pull/11595/head
ulferts 2 years ago committed by GitHub
commit d207187c4b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      frontend/src/app/features/work-packages/components/wp-single-view-tabs/files-tab/op-files-tab.component.ts
  2. 12
      frontend/src/app/shared/components/file-links/file-link-list/file-link-list.component.ts

@ -33,6 +33,7 @@ import {
} from '@angular/core';
import {
combineLatest,
merge,
Observable,
} from 'rxjs';
import {
@ -88,9 +89,12 @@ export class WorkPackageFilesTabComponent implements OnInit {
return;
}
const canViewFileLinks = this
.currentUserService
.hasCapabilities$('file_links/view', project.id);
// ToDo: Needs to be fixed after capabilities are available for anonymous user.
// https://community.openproject.org/projects/openproject/work_packages/44850/activity
const canViewFileLinks = merge(
this.currentUserService.isLoggedIn$.pipe(map((isLoggedIn) => !isLoggedIn)),
this.currentUserService.hasCapabilities$('file_links/view', project.id),
);
this.storages$ = this
.storagesResourceService

@ -87,6 +87,8 @@ export class FileLinkListComponent extends UntilDestroyedMixin implements OnInit
showLinkFilesAction = new BehaviorSubject<boolean>(false);
private isLoggedIn = false;
private readonly storageTypeMap:Record<string, string> = {};
text = {
@ -131,6 +133,10 @@ export class FileLinkListComponent extends UntilDestroyedMixin implements OnInit
this.fileLinks$ = this.fileLinkResourceService.collection(this.collectionKey);
this.currentUserService.isLoggedIn$
.pipe(this.untilDestroyed())
.subscribe((isLoggedIn) => { this.isLoggedIn = isLoggedIn; });
this.fileLinks$
.pipe(this.untilDestroyed())
.subscribe((fileLinks) => {
@ -174,6 +180,12 @@ export class FileLinkListComponent extends UntilDestroyedMixin implements OnInit
}
private instantiateStorageInformation(fileLinks:IFileLink[]):StorageInformationBox[] {
// ToDo: Replace with anonymous user capabilities check.
// https://community.openproject.org/projects/openproject/work_packages/44850/activity
if (!this.isLoggedIn) {
return [];
}
switch (this.storage._links.authorizationState.href) {
case storageFailedAuthorization:
return [this.failedAuthorizationInformation];

Loading…
Cancel
Save