feat: self-serve signup Phase 2 (frontend cutover) (#162)
Some checks failed
CI / e2e (push) Has been cancelled
CI / frontend (push) Has been cancelled
CI / backend (push) Has been cancelled
Mirror to GitHub / mirror (push) Has been cancelled

Co-authored-by: Michael Chihlas <michael@resolutionflow.com>
Co-committed-by: Michael Chihlas <michael@resolutionflow.com>
This commit was merged in pull request #162.
This commit is contained in:
2026-05-07 18:42:20 +00:00
committed by chihlasm
parent f918b766b0
commit f1be3abcc5
123 changed files with 11563 additions and 559 deletions

View File

@@ -6,6 +6,7 @@ import { authApi } from '@/api/auth'
import { identifyUser, resetAnalytics, analytics } from '@/lib/analytics'
import { apiClient } from '@/api/client'
import { clearCachedQuota } from '@/hooks/useCachedQuota'
import { useBillingStore } from '@/store/billingStore'
interface AuthState {
user: User | null
@@ -85,6 +86,7 @@ export const useAuthStore = create<AuthState>()(
localStorage.removeItem('access_token')
localStorage.removeItem('refresh_token')
clearCachedQuota()
useBillingStore.getState().reset()
Sentry.setUser(null)
resetAnalytics()
set({ user: null, token: null, account: null, subscription: null, isAuthenticated: false, error: null })
@@ -117,6 +119,11 @@ export const useAuthStore = create<AuthState>()(
identifyUser({ id: user.id, email: user.email, role: user.role, is_super_admin: user.is_super_admin, account_id: account?.id })
set({ user, account, subscription, isLoading: false })
// Kick off billing-state fetch alongside auth — fire-and-forget so
// a billing error never breaks login. The billing store records
// its own error state.
void useBillingStore.getState().fetch()
} catch (error: unknown) {
const message = error instanceof Error ? error.message : 'Failed to fetch user'
set({ error: message, isLoading: false })
@@ -124,7 +131,13 @@ export const useAuthStore = create<AuthState>()(
}
},
setTokens: (token: Token) => set({ token }),
// Storing tokens implies an active session — mark the store as
// authenticated so <ProtectedRoute> doesn't bounce the user back to
// /landing while fetchUser() is still inflight (e.g. immediately after
// the OAuth callback exchange). The refresh interceptor in api/client.ts
// also calls this; that path is already authenticated, so flipping the
// flag has no effect there.
setTokens: (token: Token) => set({ token, isAuthenticated: true }),
clearError: () => set({ error: null }),
setLoading: (loading: boolean) => set({ isLoading: loading }),
}),