feat: fix Apple OAuth issue (#2338)

* feat: fix sign in with apple bug

* fix username
This commit is contained in:
UsherFall
2023-09-18 15:42:00 +08:00
committed by Yang Luo
parent 0fc48bb6cd
commit 7f298efebc
6 changed files with 38 additions and 3 deletions

View File

@ -379,7 +379,7 @@ export function getAuthUrl(application, provider, method) {
}
let endpoint = authInfo[provider.type].endpoint;
const redirectUri = `${window.location.origin}/callback`;
let redirectUri = `${window.location.origin}/callback`;
const scope = authInfo[provider.type].scope;
const isShortState = provider.type === "WeChat" && navigator.userAgent.includes("MicroMessenger");
@ -390,6 +390,8 @@ export function getAuthUrl(application, provider, method) {
if (provider.domain !== "") {
endpoint = endpoint.replace("common", provider.domain);
}
} else if (provider.type === "Apple") {
redirectUri = `${window.location.origin}/api/callback`;
}
if (provider.type === "Google" || provider.type === "GitHub" || provider.type === "QQ" || provider.type === "Facebook"
@ -448,7 +450,7 @@ export function getAuthUrl(application, provider, method) {
} else if (provider.type === "Infoflow") {
return `${endpoint}?appid=${provider.clientId}&redirect_uri=${redirectUri}?state=${state}`;
} else if (provider.type === "Apple") {
return `${endpoint}?client_id=${provider.clientId}&redirect_uri=${redirectUri}&state=${state}&response_type=code&scope=${scope}&response_mode=form_post`;
return `${endpoint}?client_id=${provider.clientId}&redirect_uri=${redirectUri}&state=${state}&response_type=code%20id_token&scope=${scope}&response_mode=form_post`;
} else if (provider.type === "Steam") {
return `${endpoint}?openid.claimed_id=http://specs.openid.net/auth/2.0/identifier_select&openid.identity=http://specs.openid.net/auth/2.0/identifier_select&openid.mode=checkid_setup&openid.ns=http://specs.openid.net/auth/2.0&openid.realm=${window.location.origin}&openid.return_to=${redirectUri}?state=${state}`;
} else if (provider.type === "Okta") {