这是indexloc提供的服务,不要输入任何密码
Skip to content

Fix handling of route parameters in RootLayout component #347

@DennisAlund

Description

@DennisAlund

Context

In the application, the RootLayout component currently lacks proper handling for cases when:

  1. The site parameter is not present in the route.
  2. The site parameter cannot be found in the database.
  3. 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

  1. Handle Missing site Parameter:

    • Modify the RootLayout component to check if the site parameter is present in the route.
    • If the site parameter is missing, redirect the user to a 404 page.
  2. Handle Non-existing Site in Database:

    • Update the useEffect hook to handle the case where the getSite function does not return any data.
    • If the getSite function returns null or undefined, redirect the user to a 404 page.
  3. 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 from next/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

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions