fix: update token retrieval logic in handleRedirectCallback and remove unused parseSSE function

This commit is contained in:
Mabe
2026-06-21 17:14:19 +02:00
parent fd453013fd
commit c440f5aa1e
2 changed files with 5 additions and 19 deletions
+4 -18
View File
@@ -165,29 +165,15 @@ async function handleRedirectCallback(): Promise<string | null> {
})
const result = await response.json()
if (response.ok && result.access_token) {
setLocalToken(result.access_token)
return result.access_token
const token = result.id_token || result.access_token
if (response.ok && token) {
setLocalToken(token)
return token
}
throw new Error(result.error_description || 'OIDC callback failed')
}
function parseSSE(text: string, onData: (chunk: string) => void) {
const events = text.split('\n\n')
for (const event of events) {
const trimmed = event.trim()
if (!trimmed) continue
const lines = trimmed.split('\n')
const dataLines = lines
.filter((line) => line.startsWith('data:'))
.map((line) => line.replace(/^data:\s?/, ''))
if (dataLines.length) {
onData(dataLines.join('\n'))
}
}
}
function App() {
const [messages, setMessages] = useState<Message[]>([])
const [input, setInput] = useState('')