Skip to content

Commit 5b1cf67

Browse files
committed
feat(web): handle disabled registration error
1 parent 945c31a commit 5b1cf67

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

frontend/apps/web/src/stores/authStore.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { create } from 'zustand'
2+
import { isAxiosError } from 'axios'
23
import type { User, UserSettings } from '@glean/types'
34
import { authService } from '@glean/api-client'
45

@@ -60,7 +61,12 @@ export const useAuthStore = create<AuthState>((set) => ({
6061
isLoading: false,
6162
})
6263
} catch (error) {
63-
const message = error instanceof Error ? error.message : 'Registration failed'
64+
let message = 'Registration failed'
65+
if (isAxiosError(error) && error.response?.data?.detail) {
66+
message = error.response.data.detail
67+
} else if (error instanceof Error) {
68+
message = error.message
69+
}
6470
set({ error: message, isLoading: false })
6571
throw error
6672
}

0 commit comments

Comments
 (0)