fix(auth): handle saml logout and xml encryption padding
This commit is contained in:
@@ -24,6 +24,10 @@ export interface AuthConfig {
|
||||
sso_enabled: boolean
|
||||
}
|
||||
|
||||
export interface LogoutResponse {
|
||||
logout_url?: string
|
||||
}
|
||||
|
||||
export const authApi = {
|
||||
async getConfig(): Promise<ApiResponse<AuthConfig>> {
|
||||
const response = await fetch('/auth/api/v1/config', {
|
||||
@@ -64,7 +68,7 @@ export const authApi = {
|
||||
}
|
||||
},
|
||||
|
||||
async logout(): Promise<ApiResponse<null>> {
|
||||
async logout(): Promise<ApiResponse<LogoutResponse>> {
|
||||
const token = getToken()
|
||||
const response = await fetch('/auth/api/v1/logout', {
|
||||
method: 'POST',
|
||||
@@ -78,7 +82,14 @@ export const authApi = {
|
||||
const data = await response.json().catch(() => ({}))
|
||||
throw new Error(data.error || `HTTP ${response.status}`)
|
||||
}
|
||||
return { code: 0, message: 'success', data: null }
|
||||
const data = await response.json().catch(() => ({}))
|
||||
return {
|
||||
code: 0,
|
||||
message: 'success',
|
||||
data: {
|
||||
logout_url: data.logout_url || '',
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
async getUserInfo(): Promise<ApiResponse<UserInfo>> {
|
||||
|
||||
@@ -13,11 +13,13 @@ export function useAuth() {
|
||||
}
|
||||
|
||||
const logout = async () => {
|
||||
let logoutUrl = ''
|
||||
try {
|
||||
await authApi.logout()
|
||||
const response = await authApi.logout()
|
||||
logoutUrl = response.data.logout_url || ''
|
||||
} finally {
|
||||
authStore.clearAuth()
|
||||
window.location.assign('/login?logged_out=1')
|
||||
window.location.assign(logoutUrl || '/login?logged_out=1')
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user