mirror of
https://gitee.com/bootx/dax-pay-ui
synced 2026-08-12 23:45:39 +08:00
fix(social): 支付宝登录/绑定统一走专用授权入口
抽取 renderSocialAuth,登录页与个人中心绑定共用;跳转型配置提交非空占位并保证 enabled 布尔落库。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -209,3 +209,17 @@ export const AlipayAuthApi = {
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* 统一生成三方授权地址
|
||||
* 支付宝走专用端点, 其余走 JustAuth 标准 render
|
||||
*/
|
||||
export function renderSocialAuth(
|
||||
source: string,
|
||||
client: string = 'admin',
|
||||
mode?: string,
|
||||
): Promise<Result<string>> {
|
||||
return source === 'alipay'
|
||||
? AlipayAuthApi.render(client, mode)
|
||||
: SocialApi.render(source, client, mode);
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
import { $t } from '@vben/locales';
|
||||
|
||||
import { AlipayAuthApi, SocialApi } from '#/api/iam/social.api';
|
||||
import { renderSocialAuth, SocialApi } from '#/api/iam/social.api';
|
||||
import { SocialLogo } from '#/components/social';
|
||||
|
||||
defineOptions({ name: 'AuthThirdPartyPanel' });
|
||||
@@ -44,10 +44,7 @@
|
||||
const ok = await props.ensureAgreement();
|
||||
if (!ok) return;
|
||||
}
|
||||
const { data: url } =
|
||||
source === 'alipay'
|
||||
? await AlipayAuthApi.render('admin', props.mode)
|
||||
: await SocialApi.render(source, 'admin', props.mode);
|
||||
const { data: url } = await renderSocialAuth(source, 'admin', props.mode);
|
||||
if (url) {
|
||||
// 跳转到第三方授权页, 授权后由后端回调处理并重定向回前端 /oauth-callback
|
||||
window.location.href = url;
|
||||
|
||||
@@ -183,7 +183,7 @@
|
||||
// 跳转型统一走编辑接口: 非空占位过 NotBlank(真实凭据在平台配置页, 后端忽略这两字段)
|
||||
await SocialLoginConfigApi.update({
|
||||
source: formData.source,
|
||||
enabled: formData.enabled,
|
||||
enabled: !!formData.enabled,
|
||||
clientId: '-',
|
||||
clientSecret: '-',
|
||||
});
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
import { $t } from '@vben/locales';
|
||||
|
||||
import { SocialApi } from '#/api/iam/social.api';
|
||||
import { renderSocialAuth, SocialApi } from '#/api/iam/social.api';
|
||||
import { SocialLogo } from '#/components/social';
|
||||
import { useMessage } from '#/hooks/useMessage';
|
||||
|
||||
@@ -47,9 +47,10 @@
|
||||
|
||||
/**
|
||||
* 绑定第三方账号(打开弹窗进行授权, 授权后弹窗自动关闭并通知刷新)
|
||||
* 支付宝走专用端点, 与登录页 renderSocialAuth 一致
|
||||
*/
|
||||
async function handleBind(source: string) {
|
||||
const { data: url } = await SocialApi.render(source, 'admin', 'BIND');
|
||||
const { data: url } = await renderSocialAuth(source, 'admin', 'BIND');
|
||||
if (url) {
|
||||
window.open(url, 'social-bind', 'width=600,height=700');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user