-
Notifications
You must be signed in to change notification settings - Fork 41
Closed
Labels
priority:medium 👍Regular priority issueRegular priority issuetype:bug 🐛Something isn't workingSomething isn't working
Description
Context
In the application, the RootLayout
component currently lacks proper handling for cases when:
- The
site
parameter is not present in the route. - The
site
parameter cannot be found in the database. - The user does not have access to the site, which should result in the same action as if the site does not exist.
Description
The following tasks need to be completed to properly handle the above scenarios in the RootLayout
component:
Tasks
-
Handle Missing
site
Parameter:- Modify the
RootLayout
component to check if thesite
parameter is present in the route. - If the
site
parameter is missing, redirect the user to a 404 page.
- Modify the
-
Handle Non-existing Site in Database:
- Update the
useEffect
hook to handle the case where thegetSite
function does not return any data. - If the
getSite
function returnsnull
orundefined
, redirect the user to a 404 page.
- Update the
-
Handle Access Control:
- Integrate access control checks to determine if the user has permission to access the requested site.
- If the user does not have access, treat it as if the site does not exist and redirect the user to a 404 page.
Additional Notes
- Ensure that all redirects to the 404 page are performed using Next.js routing capabilities.
- The
notFound
function fromnext/navigation
should be used to handle 404 redirections. - The component should properly manage the loading state to display a loader while the checks are being performed.
Expected Outcome
Upon completing these tasks, the RootLayout
component will:
- Redirect to a 404 page if the
site
parameter is missing from the route. - Redirect to a 404 page if the
site
cannot be found in the database. - Redirect to a 404 page if the user does not have access to the site.
This will ensure a consistent and user-friendly error handling mechanism for accessing sites within the application.
Metadata
Metadata
Assignees
Labels
priority:medium 👍Regular priority issueRegular priority issuetype:bug 🐛Something isn't workingSomething isn't working