feat(settings): support per-channel WeChat OAuth and persist payment options

This commit is contained in:
IanShaw027
2026-04-21 07:48:42 -07:00
parent d5819181ea
commit 54dc176725
16 changed files with 1015 additions and 404 deletions

View File

@@ -753,7 +753,13 @@ func (h *AuthHandler) ensureWeChatBindOwnership(
}
for _, identity := range identities {
if identity != nil && identity.UserID != userID {
return infraerrors.Conflict("AUTH_IDENTITY_OWNERSHIP_CONFLICT", "auth identity already belongs to another user")
activeOwner, lookupErr := findActiveUserByID(ctx, client, identity.UserID)
if lookupErr != nil {
return lookupErr
}
if activeOwner != nil {
return infraerrors.Conflict("AUTH_IDENTITY_OWNERSHIP_CONFLICT", "auth identity already belongs to another user")
}
}
}
@@ -778,7 +784,13 @@ func (h *AuthHandler) ensureWeChatBindOwnership(
}
for _, channel := range channels {
if channel != nil && channel.Edges.Identity != nil && channel.Edges.Identity.UserID != userID {
return infraerrors.Conflict("AUTH_IDENTITY_CHANNEL_OWNERSHIP_CONFLICT", "auth identity channel already belongs to another user")
activeOwner, lookupErr := findActiveUserByID(ctx, client, channel.Edges.Identity.UserID)
if lookupErr != nil {
return lookupErr
}
if activeOwner != nil {
return infraerrors.Conflict("AUTH_IDENTITY_CHANNEL_OWNERSHIP_CONFLICT", "auth identity channel already belongs to another user")
}
}
}
return nil
@@ -960,8 +972,8 @@ func (h *AuthHandler) getWeChatOAuthConfig(ctx context.Context, rawMode string,
cfg := wechatOAuthConfig{
mode: mode,
appID: strings.TrimSpace(effective.AppID),
appSecret: strings.TrimSpace(effective.AppSecret),
appID: strings.TrimSpace(effective.AppIDForMode(mode)),
appSecret: strings.TrimSpace(effective.AppSecretForMode(mode)),
redirectURI: firstNonEmpty(strings.TrimSpace(effective.RedirectURL), resolveWeChatOAuthAbsoluteURL(apiBaseURL, c, "/api/v1/auth/oauth/wechat/callback")),
frontendCallback: firstNonEmpty(strings.TrimSpace(effective.FrontendRedirectURL), wechatOAuthDefaultFrontendCB),
scope: effective.ScopeForMode(mode),