diff --git a/frontend/src/app.ts b/frontend/src/app.ts index 20147e6..577ccb7 100644 --- a/frontend/src/app.ts +++ b/frontend/src/app.ts @@ -43,6 +43,10 @@ class App { isLoggedIn() { return this.user != null && this.token != null; } + + canUpload() { + return this.isLoggedIn() && (this.user?.can_upload || this.isAdmin()); + } } export const app = new App(); \ No newline at end of file diff --git a/frontend/src/pages/publish_page.tsx b/frontend/src/pages/publish_page.tsx index 807e104..a86ea48 100644 --- a/frontend/src/pages/publish_page.tsx +++ b/frontend/src/pages/publish_page.tsx @@ -94,7 +94,7 @@ export default function PublishPage() { return } - if (!app.user?.is_admin) { + if (!app.canUpload()) { return } diff --git a/frontend/src/pages/resource_details_page.tsx b/frontend/src/pages/resource_details_page.tsx index bcfc0b4..923f616 100644 --- a/frontend/src/pages/resource_details_page.tsx +++ b/frontend/src/pages/resource_details_page.tsx @@ -272,7 +272,7 @@ function Files({files, resourceID}: { files: RFile[], resourceID: number }) { }
{ - app.isAdmin() &&
+ app.canUpload() &&
}