Require CoinPay userinfo identity (#21)

This commit is contained in:
phucnguyen1707 2026-06-14 13:01:15 +07:00 committed by GitHub
parent 63ccad6d2a
commit 14fe9d608f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 36 additions and 1 deletions

View file

@ -74,10 +74,17 @@ export async function GET(request: NextRequest) {
});
const userText = await userResponse.text();
const userInfo = userResponse.ok ? parseJson(userText) : {};
if (!userResponse.ok || typeof userInfo.sub !== "string" || userInfo.sub.trim() === "") {
console.error("[coinpay-oauth] userinfo failed", {
status: userResponse.status,
error: userResponse.ok ? "missing_sub" : userText.slice(0, 160)
});
return redirectWithOAuthStatus("error", "userinfo_failed");
}
const session = signSession({
provider: "coinpay",
sub: typeof userInfo.sub === "string" ? userInfo.sub : null,
sub: userInfo.sub,
email: typeof userInfo.email === "string" ? userInfo.email : null,
name: typeof userInfo.name === "string" ? userInfo.name : null,
scope: typeof tokenPayload.scope === "string" ? tokenPayload.scope : config.scopes,