feat: require owner login and add onboarding

This commit is contained in:
2026-09-28 19:14:14 +09:00
parent 57882cf5f9
commit 85d23a328b
42 changed files with 2400 additions and 23 deletions
+34
View File
@@ -0,0 +1,34 @@
export type SafeOwner = {
id: number
email: string
name: string
onboardingCompletedAt: number | null
}
export type AuthState = { needsSetup: boolean; owner: SafeOwner | null }
type AuthInput =
| { action: 'login'; email: string; password: string }
| {
action: 'setup'
email: string
password: string
name: string
setupToken: string
}
| { action: 'logout' }
| { action: 'onboard'; name: string }
export async function authRequest(input: AuthInput): Promise<AuthState> {
const response = await fetch('/api/auth', {
method: 'POST',
credentials: 'same-origin',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(input),
})
const result = await response.json()
if (!response.ok) {
throw new Error(result.error || 'Something went wrong. Please try again.')
}
return result
}