summaryrefslogtreecommitdiffhomepage
path: root/packages/console/function
diff options
context:
space:
mode:
authorFrank <[email protected]>2025-12-26 17:32:37 -0500
committerFrank <[email protected]>2025-12-26 17:32:39 -0500
commit52b99622ad0c01d11a5f8a5826ed955f6aa13dca (patch)
tree8fd3e0fb81b115276dac2fb6a84a9e4c825b12b2 /packages/console/function
parenta15397cd89881c36c19b3f909ebceddb47aeca90 (diff)
downloadopencode-52b99622ad0c01d11a5f8a5826ed955f6aa13dca.tar.gz
opencode-52b99622ad0c01d11a5f8a5826ed955f6aa13dca.zip
zen: add context for login errors
Diffstat (limited to 'packages/console/function')
-rw-r--r--packages/console/function/src/auth.ts6
1 files changed, 5 insertions, 1 deletions
diff --git a/packages/console/function/src/auth.ts b/packages/console/function/src/auth.ts
index 742e0d567..082564b21 100644
--- a/packages/console/function/src/auth.ts
+++ b/packages/console/function/src/auth.ts
@@ -123,7 +123,11 @@ export default {
},
}).then((x) => x.json())) as any
subject = user.id.toString()
- email = emails.find((x: any) => x.primary && x.verified)?.email
+
+ const primaryEmail = emails.find((x: any) => x.primary)
+ if (!primaryEmail) throw new Error("No primary email found for GitHub user")
+ if (!primaryEmail.verified) throw new Error("Primary email for GitHub user not verified")
+ email = primaryEmail.email
} else if (response.provider === "google") {
if (!response.id.email_verified) throw new Error("Google email not verified")
subject = response.id.sub as string