Fix WeChat MP login "state too long" bug

This commit is contained in:
Gucheng Wang
2022-09-09 11:43:54 +08:00
parent cfce5289ed
commit 94b6eb803d
3 changed files with 24 additions and 10 deletions

View File

@ -177,7 +177,9 @@ export function getAuthUrl(application, provider, method) {
let endpoint = authInfo[provider.type].endpoint;
const redirectUri = `${window.location.origin}/callback`;
const scope = authInfo[provider.type].scope;
const state = Util.getStateFromQueryParams(application.name, provider.name, method);
const isShortState = provider.type === "WeChat" && navigator.userAgent.includes("MicroMessenger");
const state = Util.getStateFromQueryParams(application.name, provider.name, method, isShortState);
if (provider.type === "Google") {
return `${endpoint}?client_id=${provider.clientId}&redirect_uri=${redirectUri}&scope=${scope}&response_type=code&state=${state}`;