fix: handle access_token only response from switchContext
This commit is contained in:
@@ -37,9 +37,9 @@ export async function createOrganization(name: string, slug: string): Promise<Or
|
||||
}
|
||||
|
||||
// * Switch context to organization (returns new token)
|
||||
export async function switchContext(organizationId: string): Promise<{ token: string, refresh_token: string }> {
|
||||
export async function switchContext(organizationId: string): Promise<{ access_token: string }> {
|
||||
// * Route in main.go is /api/v1/auth/switch-context
|
||||
return apiRequest<{ token: string, refresh_token: string }>('/auth/switch-context', {
|
||||
return apiRequest<{ access_token: string }>('/auth/switch-context', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ organization_id: organizationId }),
|
||||
})
|
||||
|
||||
@@ -123,10 +123,10 @@ export function AuthProvider({ children }: { children: React.ReactNode }) {
|
||||
console.log('Auto-switching to organization:', firstOrg.organization_name)
|
||||
|
||||
try {
|
||||
const { token, refresh_token } = await switchContext(firstOrg.organization_id)
|
||||
const { access_token } = await switchContext(firstOrg.organization_id)
|
||||
|
||||
// * Update session cookie
|
||||
const result = await setSessionAction(token, refresh_token)
|
||||
const result = await setSessionAction(access_token)
|
||||
if (result.success && result.user) {
|
||||
setUser(result.user)
|
||||
localStorage.setItem('user', JSON.stringify(result.user))
|
||||
|
||||
Reference in New Issue
Block a user