You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Issue [Enhancement] Enhance useAuth hook with user context and session persistence
Tier: 🟡 Medium
Description:
Problem: The useAuth hook in src/hooks/useAuth.ts only checks for the existence of a token string in localStorage. It provides no user information (role, email, org ID), no logout function, and no way to refresh auth state after login. Components needing user details (like CompanyDashboard for enterpriseId or UserManagement for role-based access) have no centralized source of truth.
Implementation: Enhance useAuth to: (1) decode the JWT payload to extract user info (id, email, role, organizationId), (2) expose a user object, logout() function, and refreshAuth() method, (3) create an AuthContext provider wrapping the app so all components can access auth state without prop drilling.
Domain: Authentication
Issue [Enhancement] Enhance useAuth hook with user context and session persistence
Tier: 🟡 Medium
Description:
useAuthhook insrc/hooks/useAuth.tsonly checks for the existence of a token string in localStorage. It provides no user information (role, email, org ID), no logout function, and no way to refresh auth state after login. Components needing user details (likeCompanyDashboardforenterpriseIdorUserManagementfor role-based access) have no centralized source of truth.useAuthto: (1) decode the JWT payload to extract user info (id, email, role, organizationId), (2) expose auserobject,logout()function, andrefreshAuth()method, (3) create anAuthContextprovider wrapping the app so all components can access auth state without prop drilling.Dependencies:
Acceptance Criteria:
useAuthreturns{ isLoading, isAuthenticated, user, logout, refreshAuth }.userobject includesid,email,name,role, andorganizationIdfrom the token.logout()clears token, resets state, and navigates to/login.AuthContextprovider wraps the app in the component tree.useAuth()from any level without prop drilling.Testing Requirements:
logout()clearing state and storage.PR Checklist:
feature/issue-15-useauth-enhancement).pnpm run lintandpnpm run buildpass with zero warnings.