Implement activation requirement for protected routes
- Added a new `useRequireActivated` hook to enforce user activation before accessing certain routes, redirecting unauthenticated users to the login page and inactive users to the dashboard. - Updated the `InstructionsPage` and `NewsPage` components to utilize the new activation check, enhancing user flow and security. - Conditional rendering of navigation links in the `RootLayout` based on user activation status, improving user experience by hiding inaccessible features.
This commit is contained in:
@@ -44,12 +44,16 @@ function RootLayout() {
|
||||
<Link to="/dashboard" className="text-muted-foreground hover:text-foreground">
|
||||
{t('nav.dashboard')}
|
||||
</Link>
|
||||
<Link to="/instructions" className="text-muted-foreground hover:text-foreground">
|
||||
{t('nav.instructions')}
|
||||
</Link>
|
||||
<Link to="/news" className="text-muted-foreground hover:text-foreground">
|
||||
{t('nav.news')}
|
||||
</Link>
|
||||
{user.isActivated && (
|
||||
<>
|
||||
<Link to="/instructions" className="text-muted-foreground hover:text-foreground">
|
||||
{t('nav.instructions')}
|
||||
</Link>
|
||||
<Link to="/news" className="text-muted-foreground hover:text-foreground">
|
||||
{t('nav.news')}
|
||||
</Link>
|
||||
</>
|
||||
)}
|
||||
<Link to="/settings" className="text-muted-foreground hover:text-foreground">
|
||||
{t('nav.settings')}
|
||||
</Link>
|
||||
|
||||
Reference in New Issue
Block a user