summaryrefslogtreecommitdiffhomepage
path: root/cloud/function/src
diff options
context:
space:
mode:
authorDax Raad <[email protected]>2025-09-03 14:32:05 -0400
committerDax Raad <[email protected]>2025-09-03 14:32:05 -0400
commit469a83a55b67660182747580d8cfabe7b21bcfb6 (patch)
tree0a9f668772f58455ecd16afd7ef51b2b1c724946 /cloud/function/src
parente8f54b9b382616b0d6d082662bdedeb54a28b3cb (diff)
downloadopencode-469a83a55b67660182747580d8cfabe7b21bcfb6.tar.gz
opencode-469a83a55b67660182747580d8cfabe7b21bcfb6.zip
wip: email
Diffstat (limited to 'cloud/function/src')
-rw-r--r--cloud/function/src/auth.ts7
1 files changed, 3 insertions, 4 deletions
diff --git a/cloud/function/src/auth.ts b/cloud/function/src/auth.ts
index bda02cd87..776855e46 100644
--- a/cloud/function/src/auth.ts
+++ b/cloud/function/src/auth.ts
@@ -100,15 +100,14 @@ export default {
let email: string | undefined
if (response.provider === "github") {
- const userResponse = await fetch("https://api.github.com/user", {
+ const emails = (await fetch("https://api.github.com/user/emails", {
headers: {
Authorization: `Bearer ${response.tokenset.access}`,
"User-Agent": "opencode",
Accept: "application/vnd.github+json",
},
- })
- const user = (await userResponse.json()) as { email: string }
- email = user.email
+ }).then((x) => x.json())) as any
+ email = emails.find((x: any) => x.primary && x.verified)?.email
} else if (response.provider === "google") {
if (!response.id.email_verified) throw new Error("Google email not verified")
email = response.id.email as string