Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

/dashboard/teams/[accountId]/settings/* pages not protected from team members #48

Closed
gmarcus opened this issue Sep 8, 2023 · 2 comments

Comments

@gmarcus
Copy link

gmarcus commented Sep 8, 2023

Great project so far.

Found an edge case when I have a team member (not owner) that is able to access settings pages. Even though the sidebar hides the menu item Settings, a member can simply enter the URLs for the settings.

RLS prevents a team member from updating settings, but they should not be able to view/interact with the pages at all.

Here is a screenshot of a team member that is able to view the the settings/members page:

CleanShot 2023-09-08 at 01 05 20

If a member accesses a nested Settings page, they should be redirected to the Team Dashboard.
Even though RLS is taking care of the data, what is a good pattern to protect routes?

@jamesthesken
Copy link

jamesthesken commented Sep 19, 2023

@gmarcus You could use something like this, I think:

const router = useRouter();
const { accountId } = router.query;

const { accountRole } = useTeamRole(accountId as string);

if (accountRole === "member") {
  // push the member back to the home page, dashboard, etc.
  router.push("/");
}

@tiniscule
Copy link
Contributor

Closing because the Next portion of this has been moved to a different repo - I'll be doing some work there shortly to simplify the starter kit to avoid things like this. Thanks for the report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants