Skip to content

Commit

Permalink
Merge pull request #808 from photonia-io/fix-unauthorized-upload-admi…
Browse files Browse the repository at this point in the history
…n-settings

Fix unathorized to access 'Upload' and 'Admin settings' pages
  • Loading branch information
janosrusiczki authored Nov 21, 2024
2 parents d0758d5 + d2abff9 commit 797782b
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions app/javascript/entrypoints/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ document.addEventListener("DOMContentLoaded", () => {
}
};

const redirectUnauthorized = (isAuthorized) => (to, from) => {
if (!isAuthorized) {
const redirectIfUnauthorized = (key) => (to, from) => {
if (!userStore[key]) {
toaster("You are not authorized to access that page.", "is-warning");
return { name: "root" };
}
Expand Down Expand Up @@ -104,19 +104,13 @@ document.addEventListener("DOMContentLoaded", () => {
path: settings.users_admin_settings_path,
name: "users-admin-settings",
component: () => import("../users/admin-settings.vue"),
beforeEnter: [
redirectIfNotSignedIn,
redirectUnauthorized(userStore.admin),
],
beforeEnter: [redirectIfNotSignedIn, redirectIfUnauthorized("admin")],
},
{
path: settings.photos_path + "/upload",
name: "photos-upload",
component: () => import("../photos/upload.vue"),
beforeEnter: [
redirectIfNotSignedIn,
redirectUnauthorized(userStore.uploader),
],
beforeEnter: [redirectIfNotSignedIn, redirectIfUnauthorized("uploader")],
},
{
path: settings.photos_path + "/organizer",
Expand Down

0 comments on commit 797782b

Please sign in to comment.