mirror of
https://github.com/coder/coder.git
synced 2026-10-24 11:43:39 +08:00
fix(site): Fix login flow (#6294)
This commit is contained in:
+13
-3
@@ -101,9 +101,19 @@ export const logout = async (): Promise<void> => {
|
||||
await axios.post("/api/v2/users/logout")
|
||||
}
|
||||
|
||||
export const getUser = async (): Promise<TypesGen.User> => {
|
||||
const response = await axios.get<TypesGen.User>("/api/v2/users/me")
|
||||
return response.data
|
||||
export const getAuthenticatedUser = async (): Promise<
|
||||
TypesGen.User | undefined
|
||||
> => {
|
||||
try {
|
||||
const response = await axios.get<TypesGen.User>("/api/v2/users/me")
|
||||
return response.data
|
||||
} catch (error) {
|
||||
if (axios.isAxiosError(error) && error.response?.status === 401) {
|
||||
return undefined
|
||||
}
|
||||
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
export const getAuthMethods = async (): Promise<TypesGen.AuthMethods> => {
|
||||
|
||||
Reference in New Issue
Block a user