wip: email
This commit is contained in:
@@ -100,15 +100,14 @@ export default {
|
|||||||
let email: string | undefined
|
let email: string | undefined
|
||||||
|
|
||||||
if (response.provider === "github") {
|
if (response.provider === "github") {
|
||||||
const userResponse = await fetch("https://api.github.com/user", {
|
const emails = (await fetch("https://api.github.com/user/emails", {
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Bearer ${response.tokenset.access}`,
|
Authorization: `Bearer ${response.tokenset.access}`,
|
||||||
"User-Agent": "opencode",
|
"User-Agent": "opencode",
|
||||||
Accept: "application/vnd.github+json",
|
Accept: "application/vnd.github+json",
|
||||||
},
|
},
|
||||||
})
|
}).then((x) => x.json())) as any
|
||||||
const user = (await userResponse.json()) as { email: string }
|
email = emails.find((x: any) => x.primary && x.verified)?.email
|
||||||
email = user.email
|
|
||||||
} else if (response.provider === "google") {
|
} else if (response.provider === "google") {
|
||||||
if (!response.id.email_verified) throw new Error("Google email not verified")
|
if (!response.id.email_verified) throw new Error("Google email not verified")
|
||||||
email = response.id.email as string
|
email = response.id.email as string
|
||||||
|
|||||||
Reference in New Issue
Block a user