mirror of
https://github.com/wgh136/nysoure.git
synced 2025-09-27 12:17:24 +00:00
Fix uploads for non-admin users
This commit is contained in:
@@ -43,6 +43,10 @@ class App {
|
|||||||
isLoggedIn() {
|
isLoggedIn() {
|
||||||
return this.user != null && this.token != null;
|
return this.user != null && this.token != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
canUpload() {
|
||||||
|
return this.isLoggedIn() && (this.user?.can_upload || this.isAdmin());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const app = new App();
|
export const app = new App();
|
@@ -94,7 +94,7 @@ export default function PublishPage() {
|
|||||||
return <ErrorAlert className={"m-4"} message={t("You are not logged in. Please log in to access this page.")} />
|
return <ErrorAlert className={"m-4"} message={t("You are not logged in. Please log in to access this page.")} />
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!app.user?.is_admin) {
|
if (!app.canUpload()) {
|
||||||
return <ErrorAlert className={"m-4"} message={t("You are not authorized to access this page.")} />
|
return <ErrorAlert className={"m-4"} message={t("You are not authorized to access this page.")} />
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -272,7 +272,7 @@ function Files({files, resourceID}: { files: RFile[], resourceID: number }) {
|
|||||||
}
|
}
|
||||||
<div className={"h-2"}></div>
|
<div className={"h-2"}></div>
|
||||||
{
|
{
|
||||||
app.isAdmin() && <div className={"flex flex-row-reverse"}>
|
app.canUpload() && <div className={"flex flex-row-reverse"}>
|
||||||
<CreateFileDialog resourceId={resourceID}></CreateFileDialog>
|
<CreateFileDialog resourceId={resourceID}></CreateFileDialog>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user