+
绑定
@@ -214,7 +214,7 @@ async function loadOauthProviders() {
const computedOauthBounds = computed(() => {
const list = oauthProviders.value.map(item => {
- const bound = oauthBounds.value.find(bound => bound.type === item.name);
+ const bound = oauthBounds.value.find(bound => bound.type === buildOauthBoundType(item));
return {
...item,
bound,
@@ -223,20 +223,24 @@ const computedOauthBounds = computed(() => {
return list;
});
-async function unbind(type: string) {
+function buildOauthBoundType(item: any) {
+ return item.subtype ? `${item.name}:${item.subtype}` : item.name;
+}
+
+async function unbind(item: any) {
Modal.confirm({
title: "确认解绑吗?",
okText: "确认",
okType: "danger",
onOk: async () => {
- await api.UnbindOauth(type);
+ await api.UnbindOauth(item.name, item.subtype);
await loadOauthBounds();
},
});
}
-async function bind(type: string) {
- const res = await api.OauthBoundUrl(type);
+async function bind(item: any) {
+ const res = await api.OauthBoundUrl(item.name, item.subtype);
const loginUrl = res.loginUrl;
window.location.href = loginUrl;
}
diff --git a/packages/ui/certd-client/src/views/framework/oauth/api.ts b/packages/ui/certd-client/src/views/framework/oauth/api.ts
index 1c5ab8ae5..2149b767a 100644
--- a/packages/ui/certd-client/src/views/framework/oauth/api.ts
+++ b/packages/ui/certd-client/src/views/framework/oauth/api.ts
@@ -2,7 +2,7 @@ import { request } from "/src/api/service";
const apiPrefix = "/oauth";
-export async function OauthLogin(type: string, forType?: string, from?: string) {
+export async function OauthLogin(type: string, forType?: string, from?: string, subtype?: string) {
return await request({
url: apiPrefix + `/login`,
method: "post",
@@ -10,6 +10,7 @@ export async function OauthLogin(type: string, forType?: string, from?: string)
type,
forType: forType || "login",
from: from || "web",
+ subtype,
},
});
}
diff --git a/packages/ui/certd-client/src/views/framework/oauth/oauth-callback.vue b/packages/ui/certd-client/src/views/framework/oauth/oauth-callback.vue
index 05035cb51..9b05a6c8e 100644
--- a/packages/ui/certd-client/src/views/framework/oauth/oauth-callback.vue
+++ b/packages/ui/certd-client/src/views/framework/oauth/oauth-callback.vue
@@ -9,8 +9,9 @@
第三方({{ oauthType }})登录成功,您还未绑定账号,请选择
-
绑定已有账号
-
创建新账号
+
绑定已有账号
+
绑定当前登录账号({{ userStore.getUserInfo.username }} - {{ userStore.getUserInfo.nickName }})
+
创建新账号绑定
@@ -63,6 +64,15 @@ async function handleOauthToken() {
}
}
+async function doBindCurrent() {
+ await api.BindUser(validationCode);
+ notification.success({
+ message: "绑定成功",
+ });
+ //跳转到首页
+ router.replace("/certd/mine/user-profile");
+}
+
onMounted(async () => {
if (error.value) {
return;
@@ -70,12 +80,7 @@ onMounted(async () => {
if (forType === "bind") {
//从用户中心页面,进行第三方账号的绑定
- await api.BindUser(validationCode);
- notification.success({
- message: "绑定成功",
- });
- //跳转到首页
- router.replace("/certd/mine/user-profile");
+ await doBindCurrent();
return;
}
@@ -98,7 +103,7 @@ async function autoRegister() {
//登录成功
userStore.onLoginSuccess(res);
//跳转到首页
- router.replace("/");
+ router.replace("/index");
}