Skip to content
This repository has been archived by the owner on Jun 9, 2023. It is now read-only.

Logic in the dashboard that redirects the user when they don't have permission #2122

Open
Sboonny opened this issue Dec 20, 2022 · 3 comments
Labels
UI/UX This issue deals with UI/UX

Comments

@Sboonny
Copy link
Member

Sboonny commented Dec 20, 2022

Describe the feature
I have discussed this with @ojeytonwilliams today about adding status can't access error which turned to redirect users, I am opening an issue to document it (so I don't forget), and get your opinions.

Currently, we are hiding the component that people can't interact with in the dashboard, instead of doing that I thought of displaying "can't access" error in layout, when they don't have permission.

Oilver had a better idea, we can use /dashboard and add logic which direct users to the page they want, or can't access error if they don't have it.

This will make it easier to find the logic and update as it will be in something related to dashboard, and it would remove the need to hide some actions in the component itself.

@Sboonny Sboonny added the UI/UX This issue deals with UI/UX label Dec 20, 2022
@gikf
Copy link
Member

gikf commented Dec 26, 2022

I'm not sure if I understand how this would work. Any more specific example?

I think, if I'd click on some button and after loading next page, learned that I cannot use that button, because I don't have permission for it, I'd be pretty annoyed.

@Sboonny
Copy link
Member Author

Sboonny commented Dec 27, 2022

I will be honest, I don't remember what was discussed, and I haven't worked on it because of me taking break on holiday, so what Oliver suggested is completely lost, and we need him to give more context again. 🤦

here is the jest of what I wanted.


the layout.tsx has NextError for not logged in users, we can duplicate this and account for permission to view the children in the layout too.

here is the NextError:

if (!isLoggedIn)
return <NextError statusCode={401} title={'Log in to see this page'} />;

We can add something like this:

const hasPermission = account for permission
 if (!hasPermission) 
   return <NextError statusCode={500} title={`Can't access this page`} />; 

This will clear the need for view permission in the DataTable files

@ojeytonwilliams
Copy link
Contributor

I didn't take notes, so I'm a little hazy on what we discussed. From memory we were talking about redirecting users to a part of the dashboard they have access to, but on reflection I think that could be quite annoying. i.e. if they go to /dashboard/calendar but only have access to /dashboard/events then it'll redirect to the latter.

The current behaviour is okay, I think. We could, as Muhammed suggested, catch the fact a user doesn't have permission when we render the layout. That would give a slightly cleaner display.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
UI/UX This issue deals with UI/UX
Projects
None yet
Development

No branches or pull requests

3 participants