Appearance
Auth Store ​
File Information ​
- Path:
app/stores/auth.ts - Purpose: Manages authentication state with HTTP-only cookie support
Overview ​
The Auth Store provides centralized authentication state management with secure HTTP-only cookie support for token storage.
State ​
typescript
{
user: User | null // Current user data
accessToken: string | null // JWT access token
loading: boolean // Loading state
isAuthenticated: boolean // Computed authentication status
}Actions ​
login ​
User login with email and password.
typescript
await authStore.login(email, password, workspaceId)Returns: { success: boolean, data?: any, error?: string }
logout ​
User logout - clears session and redirects to login.
typescript
await authStore.logout()getUser ​
Fetch current user data.
typescript
await authStore.getUser()loginWithToken ​
Token-based login for one-time access links.
typescript
await authStore.loginWithToken(token, url)storeSession ​
Store session in HTTP-only cookies.
typescript
authStore.storeSession(token, userData)clearSession ​
Clear session cookies.
typescript
authStore.clearSession()Getters ​
isAuthenticated ​
Computed authentication status.
typescript
const isAuth = authStore.isAuthenticatedcurrentWorkspace ​
Current workspace data.
typescript
const workspace = authStore.currentWorkspaceUsage Example ​
typescript
const authStore = useAuthStore()
// Check authentication
if (authStore.isAuthenticated) {
// User is logged in
const user = authStore.user
}
// Login
const result = await authStore.login(email, password, workspaceId)
if (result.success) {
await authStore.getUser()
}