fix(app): provider connect oauth error handling

pull/9888/head
Adam 2026-01-21 14:25:47 -06:00
parent 6d656e4827
commit fa91337723
No known key found for this signature in database
GPG Key ID: 9CB48779AF150E75
1 changed files with 26 additions and 14 deletions

View File

@ -305,16 +305,22 @@ export function DialogConnectProvider(props: { provider: string }) {
} }
setFormStore("error", undefined) setFormStore("error", undefined)
const { error } = await globalSDK.client.provider.oauth.callback({ const result = await globalSDK.client.provider.oauth
providerID: props.provider, .callback({
method: store.methodIndex, providerID: props.provider,
code, method: store.methodIndex,
}) code,
if (!error) { })
.then((value) =>
value.error ? { ok: false as const, error: value.error } : { ok: true as const },
)
.catch((error) => ({ ok: false as const, error }))
if (result.ok) {
await complete() await complete()
return return
} }
setFormStore("error", language.t("provider.connect.oauth.code.invalid")) const message = result.error instanceof Error ? result.error.message : String(result.error)
setFormStore("error", message || language.t("provider.connect.oauth.code.invalid"))
} }
return ( return (
@ -357,13 +363,19 @@ export function DialogConnectProvider(props: { provider: string }) {
}) })
onMount(async () => { onMount(async () => {
const result = await globalSDK.client.provider.oauth.callback({ const result = await globalSDK.client.provider.oauth
providerID: props.provider, .callback({
method: store.methodIndex, providerID: props.provider,
}) method: store.methodIndex,
if (result.error) { })
// TODO: show error .then((value) =>
dialog.close() value.error ? { ok: false as const, error: value.error } : { ok: true as const },
)
.catch((error) => ({ ok: false as const, error }))
if (!result.ok) {
const message = result.error instanceof Error ? result.error.message : String(result.error)
setStore("state", "error")
setStore("error", message)
return return
} }
await complete() await complete()