Skip to content

Auth Feature

Public Summary

Handles login, session persistence, token refresh, and route protection on the client side.

Internal Details

Files

FileRole
Login.jsxLogin page with form
PersistLogin.jsxWrapper that refreshes tokens on app load
RequireAuth.jsxRoute guard — redirects to login if unauthenticated
useAuth.jsHook to access auth state
useLogout.jsHook to clear session
useRefreshToken.jsHook to silently refresh access token

State Management

  • authStore (Zustand, persisted to localStorage): stores auth object and persist flag.
  • Access token kept in memory; refresh token in httpOnly cookie.

Route Protection Flow

Dependencies

DependencyUsage
authStoreAuth state persistence
useAxiosPrivateAttach access token to API calls
Axios/login, /logout API calls

Source Anchors

PathRelevance
apps/client/src/features/auth/Login page, guards, auth hooks
apps/client/src/store/authStore.jsAuth state (Zustand, persisted)
apps/client/src/hooks/useAxiosPrivate.jsToken interceptor with 403 retry

Student Obrok engineering documentation.