Hide GPU page from users without useGpus permission and not admin
242
If a users role.permissions does not include "useGpus" and user is not an admin they will be redirected from the /gpu page if they try to access it, the button doesnt get rendered if the user isn't either an admin or has the useGpus permission.
I used "useGpus" as the permission to check since to my knowledge it is the permission that is present in the role.permissions array if a user should be able to access GPUs. Got it from here and here. Let me know if I misunderstood or if there are more permissions that needs to be checked.
The logic for redirecting a user when they try to access the page is inspired from the way it is handled in the admin page, and looks like this.
useEffect(() => {
if (!user) return;
if (!user.role.permissions.includes("useGpus") && !user.admin) {
enqueueSnackbar(t("not-permitted-to-gpu-page"), {
variant: "error",
});
navigate("/deploy");
}
}, [user]);
user without "useGpus" in their permissions array sees:user without permissions trying to access it through the url in englishuser without permissions trying to access it through the url in swedish
Hide GPU page from users without useGpus permission and not admin
242
If a users role.permissions does not include "useGpus" and user is not an admin they will be redirected from the
/gpu
page if they try to access it, the button doesnt get rendered if the user isn't either an admin or has the useGpus permission.I used "useGpus" as the permission to check since to my knowledge it is the permission that is present in the role.permissions array if a user should be able to access GPUs. Got it from here and here. Let me know if I misunderstood or if there are more permissions that needs to be checked.
The logic for redirecting a user when they try to access the page is inspired from the way it is handled in the admin page, and looks like this.
user without "useGpus" in their permissions array sees: user without permissions trying to access it through the url in english user without permissions trying to access it through the url in swedish