diff --git a/.env b/.env
index 414a776c5..87cc05619 100644
--- a/.env
+++ b/.env
@@ -129,3 +129,17 @@ CLIENT_PULL_STRATEGY_INTERVAL=90000
CLIENT_COLOR_SCHEME='{"type":"library","lat":56.0,"lng":10.0}'
CLIENT_DEBUG=false
###< Client configuration ###
+
+# TODO: Write documentation.
+# See src/Security/Voter/AuthorizationVoterValues.php for complete default authorization array.
+# Example value:
+# AUTHORIZATION_OVERRIDE='{
+# "SCREEN": {
+# "LIST": ["ROLE_EDITOR"],
+# "VIEW": ["ROLE_EDITOR"],
+# "EDIT": ["ROLE_ADMIN"],
+# "CREATE": ["ROLE_ADMIN"],
+# "DELETE": ["ROLE_ADMIN"],
+# }
+# }'
+AUTHORIZATION_OVERRIDE='{}'
diff --git a/assets/admin/app.jsx b/assets/admin/app.jsx
index 7c67ac413..988558ba5 100644
--- a/assets/admin/app.jsx
+++ b/assets/admin/app.jsx
@@ -70,7 +70,7 @@ function App() {
roles: ["ROLE_ADMIN"],
},
screen: {
- roles: ["ROLE_ADMIN"],
+ roles: ["ROLE_EDITOR", "ROLE_ADMIN"],
},
settings: {
roles: ["ROLE_ADMIN"],
diff --git a/assets/admin/components/restricted-route.jsx b/assets/admin/components/restricted-route.jsx
index eb2ef3b12..1a45bc4c8 100644
--- a/assets/admin/components/restricted-route.jsx
+++ b/assets/admin/components/restricted-route.jsx
@@ -17,6 +17,9 @@ function RestrictedRoute({ children, roles }) {
const userHasRequiredRole = context.selectedTenant.get?.roles.find((value) =>
roles.includes(value),
);
+
+ console.log("asd", roles, userHasRequiredRole, context.selectedTenant.get?.roles);
+
if (context.authenticated.get && !userHasRequiredRole) {
return ;
}
diff --git a/assets/admin/components/screen/screen-form.jsx b/assets/admin/components/screen/screen-form.jsx
index 8f64516c0..f95bc0687 100644
--- a/assets/admin/components/screen/screen-form.jsx
+++ b/assets/admin/components/screen/screen-form.jsx
@@ -83,6 +83,32 @@ function ScreenForm({
previewOrientationOptions[0].value,
);
+ const hasPermission = (entity, action) => {
+ console.log("hasPermission", entity, action);
+
+ if (config?.authorization) {
+ const currentTenant = JSON.parse(localStorage.getItem("admin-selected-tenant"));
+ const userRoles = currentTenant?.roles;
+
+ const authorization = config.authorization;
+
+ console.log("authorization", authorization);
+
+ const requiredRoles = authorization[entity]?.[action];
+
+ console.log("requiredRoles", requiredRoles);
+
+ const intersect = requiredRoles.filter(value => userRoles.includes(value));
+
+ console.log("intersect", intersect);
+
+ if (intersect.length > 0) {
+ return true;
+ }
+ }
+ return false;
+ }
+
/**
* Check if published is set
*
@@ -382,24 +408,28 @@ function ScreenForm({
>
{t("cancel-button")}
-
-
+ {hasPermission("Screen", "EDIT") && (
+ <>
+
+
+ >
+ )}
{config?.enhancedPreview && (