fix: restore wechat settings compatibility after rebase
This commit is contained in:
@@ -70,8 +70,8 @@ func TestSettingService_GetWeChatConnectOAuthConfig_UsesDatabaseOverrides(t *tes
|
||||
got, err := svc.GetWeChatConnectOAuthConfig(context.Background())
|
||||
require.NoError(t, err)
|
||||
require.True(t, got.Enabled)
|
||||
require.Equal(t, "wx-db-app", got.AppID)
|
||||
require.Equal(t, "wx-db-secret", got.AppSecret)
|
||||
require.Equal(t, "wx-db-app", got.AppIDForMode("mp"))
|
||||
require.Equal(t, "wx-db-secret", got.AppSecretForMode("mp"))
|
||||
require.True(t, got.OpenEnabled)
|
||||
require.True(t, got.MPEnabled)
|
||||
require.Equal(t, "mp", got.Mode)
|
||||
|
||||
@@ -43,9 +43,13 @@ const props = withDefaults(defineProps<{
|
||||
|
||||
const appStore = useAppStore()
|
||||
const route = useRoute()
|
||||
const { t } = useI18n()
|
||||
const { t, locale } = useI18n()
|
||||
const providerName = computed(() => t('auth.wechatProviderName'))
|
||||
|
||||
function localizeWeChatHint(zh: string, en: string): string {
|
||||
return locale.value.startsWith('zh') ? zh : en
|
||||
}
|
||||
|
||||
const resolvedStart = computed(() => resolveWeChatOAuthStart(appStore.cachedPublicSettings))
|
||||
const buttonDisabled = computed(() => props.disabled || resolvedStart.value.mode === null)
|
||||
const disabledHint = computed(() => {
|
||||
|
||||
@@ -1434,6 +1434,7 @@
|
||||
</label>
|
||||
<input
|
||||
v-model="form.wechat_connect_open_app_id"
|
||||
data-testid="wechat-connect-open-app-id"
|
||||
type="text"
|
||||
class="input font-mono text-sm"
|
||||
:placeholder="
|
||||
@@ -1452,6 +1453,7 @@
|
||||
</label>
|
||||
<input
|
||||
v-model="form.wechat_connect_open_app_secret"
|
||||
data-testid="wechat-connect-open-app-secret"
|
||||
type="password"
|
||||
class="input font-mono text-sm"
|
||||
:placeholder="
|
||||
@@ -1505,6 +1507,7 @@
|
||||
</label>
|
||||
<input
|
||||
v-model="form.wechat_connect_mp_app_id"
|
||||
data-testid="wechat-connect-mp-app-id"
|
||||
type="text"
|
||||
class="input font-mono text-sm"
|
||||
:placeholder="
|
||||
@@ -1528,6 +1531,7 @@
|
||||
</label>
|
||||
<input
|
||||
v-model="form.wechat_connect_mp_app_secret"
|
||||
data-testid="wechat-connect-mp-app-secret"
|
||||
type="password"
|
||||
class="input font-mono text-sm"
|
||||
:placeholder="
|
||||
@@ -1581,6 +1585,7 @@
|
||||
</label>
|
||||
<input
|
||||
v-model="form.wechat_connect_mobile_app_id"
|
||||
data-testid="wechat-connect-mobile-app-id"
|
||||
type="text"
|
||||
class="input font-mono text-sm"
|
||||
:placeholder="
|
||||
@@ -1599,6 +1604,7 @@
|
||||
</label>
|
||||
<input
|
||||
v-model="form.wechat_connect_mobile_app_secret"
|
||||
data-testid="wechat-connect-mobile-app-secret"
|
||||
type="password"
|
||||
class="input font-mono text-sm"
|
||||
:placeholder="
|
||||
@@ -4719,6 +4725,10 @@ const { t, locale } = useI18n();
|
||||
const appStore = useAppStore();
|
||||
const adminSettingsStore = useAdminSettingsStore();
|
||||
|
||||
function localText(zh: string, en: string): string {
|
||||
return locale.value.startsWith("zh") ? zh : en;
|
||||
}
|
||||
|
||||
type SettingsTab =
|
||||
| "general"
|
||||
| "security"
|
||||
@@ -5532,6 +5542,39 @@ async function loadSettings() {
|
||||
wechatCapabilities.mobileEnabled,
|
||||
settings.wechat_connect_mode,
|
||||
);
|
||||
const legacyWeChatAppID = String(settings.wechat_connect_app_id || "").trim();
|
||||
const legacyWeChatSecretConfigured = Boolean(
|
||||
settings.wechat_connect_app_secret_configured,
|
||||
);
|
||||
if (!form.wechat_connect_open_app_id && wechatCapabilities.openEnabled) {
|
||||
form.wechat_connect_open_app_id = legacyWeChatAppID;
|
||||
}
|
||||
if (!form.wechat_connect_mp_app_id && wechatCapabilities.mpEnabled) {
|
||||
form.wechat_connect_mp_app_id = legacyWeChatAppID;
|
||||
}
|
||||
if (!form.wechat_connect_mobile_app_id && wechatCapabilities.mobileEnabled) {
|
||||
form.wechat_connect_mobile_app_id = legacyWeChatAppID;
|
||||
}
|
||||
if (
|
||||
!form.wechat_connect_open_app_secret_configured &&
|
||||
wechatCapabilities.openEnabled
|
||||
) {
|
||||
form.wechat_connect_open_app_secret_configured =
|
||||
legacyWeChatSecretConfigured;
|
||||
}
|
||||
if (
|
||||
!form.wechat_connect_mp_app_secret_configured &&
|
||||
wechatCapabilities.mpEnabled
|
||||
) {
|
||||
form.wechat_connect_mp_app_secret_configured = legacyWeChatSecretConfigured;
|
||||
}
|
||||
if (
|
||||
!form.wechat_connect_mobile_app_secret_configured &&
|
||||
wechatCapabilities.mobileEnabled
|
||||
) {
|
||||
form.wechat_connect_mobile_app_secret_configured =
|
||||
legacyWeChatSecretConfigured;
|
||||
}
|
||||
form.wechat_connect_scopes = defaultWeChatConnectScopesForMode(
|
||||
form.wechat_connect_mode,
|
||||
);
|
||||
@@ -5689,10 +5732,6 @@ async function saveSettings() {
|
||||
}
|
||||
}
|
||||
|
||||
if (!validatePaymentVisibleMethodSelections()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (form.wechat_connect_mp_enabled && form.wechat_connect_mobile_enabled) {
|
||||
appStore.showError(
|
||||
localText(
|
||||
|
||||
@@ -664,7 +664,7 @@ describe("admin SettingsView wechat connect controls", () => {
|
||||
|
||||
expect(
|
||||
(
|
||||
wrapper.get('[data-testid="wechat-connect-app-id"]')
|
||||
wrapper.get('[data-testid="wechat-connect-mp-app-id"]')
|
||||
.element as HTMLInputElement
|
||||
).value,
|
||||
).toBe("wx-app-id-123");
|
||||
@@ -685,7 +685,7 @@ describe("admin SettingsView wechat connect controls", () => {
|
||||
);
|
||||
expect(
|
||||
wrapper
|
||||
.get('[data-testid="wechat-connect-app-secret"]')
|
||||
.get('[data-testid="wechat-connect-mp-app-secret"]')
|
||||
.attributes("placeholder"),
|
||||
).toContain("密钥已配置");
|
||||
expect(
|
||||
@@ -703,10 +703,10 @@ describe("admin SettingsView wechat connect controls", () => {
|
||||
await openSecurityTab(wrapper);
|
||||
|
||||
await wrapper
|
||||
.get('[data-testid="wechat-connect-app-id"]')
|
||||
.get('[data-testid="wechat-connect-mp-app-id"]')
|
||||
.setValue("wx-app-id-updated");
|
||||
await wrapper
|
||||
.get('[data-testid="wechat-connect-app-secret"]')
|
||||
.get('[data-testid="wechat-connect-mp-app-secret"]')
|
||||
.setValue("new-secret");
|
||||
await wrapper
|
||||
.get('[data-testid="wechat-connect-open-enabled"]')
|
||||
@@ -728,9 +728,10 @@ describe("admin SettingsView wechat connect controls", () => {
|
||||
expect.objectContaining({
|
||||
wechat_connect_enabled: true,
|
||||
wechat_connect_app_id: "wx-app-id-updated",
|
||||
wechat_connect_app_secret: "new-secret",
|
||||
wechat_connect_open_enabled: true,
|
||||
wechat_connect_mp_enabled: true,
|
||||
wechat_connect_mp_app_id: "wx-app-id-updated",
|
||||
wechat_connect_mp_app_secret: "new-secret",
|
||||
wechat_connect_redirect_url:
|
||||
"https://admin.example.com/api/v1/auth/oauth/wechat/callback",
|
||||
wechat_connect_frontend_redirect_url: "/auth/wechat/callback",
|
||||
@@ -738,13 +739,13 @@ describe("admin SettingsView wechat connect controls", () => {
|
||||
);
|
||||
expect(
|
||||
(
|
||||
wrapper.get('[data-testid="wechat-connect-app-secret"]')
|
||||
wrapper.get('[data-testid="wechat-connect-mp-app-secret"]')
|
||||
.element as HTMLInputElement
|
||||
).value,
|
||||
).toBe("");
|
||||
expect(
|
||||
wrapper
|
||||
.get('[data-testid="wechat-connect-app-secret"]')
|
||||
.get('[data-testid="wechat-connect-mp-app-secret"]')
|
||||
.attributes("placeholder"),
|
||||
).toContain("密钥已配置");
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user