diff --git a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/service/social/impl/SysSocialServiceImpl.java b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/service/social/impl/SysSocialServiceImpl.java index 3bbbceb76..e5102014a 100644 --- a/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/service/social/impl/SysSocialServiceImpl.java +++ b/yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/service/social/impl/SysSocialServiceImpl.java @@ -107,7 +107,7 @@ public class SysSocialServiceImpl implements SysSocialService { // 逻辑三:如果 authUser 不存在于 socialUsers 中,则进行新增;否则,进行更新 SysSocialUserDO socialUser = CollUtil.findOneByField(socialUsers, "openid", authUser.getUuid()); SysSocialUserDO saveSocialUser = SysSocialUserDO.builder() // 新增和更新的通用属性 - .token(authUser.getToken().getAccessToken()).rawUserInfo(toJsonString(authUser.getToken())) + .token(authUser.getToken().getAccessToken()).rawTokenInfo(toJsonString(authUser.getToken())) .nickname(authUser.getNickname()).avatar(authUser.getAvatar()).rawUserInfo(toJsonString(authUser.getRawUserInfo())) .build(); if (socialUser == null) { @@ -129,7 +129,7 @@ public class SysSocialServiceImpl implements SysSocialService { } // 校验,是否解绑的是非自己的 socialUsers.forEach(socialUser -> { - if (Objects.equals(socialUser.getUserId(), userId)) { + if (!Objects.equals(socialUser.getUserId(), userId)) { throw exception(SOCIAL_UNBIND_NOT_SELF); } }); diff --git a/yudao-admin-ui/src/api/login.js b/yudao-admin-ui/src/api/login.js index a02402d16..348aef063 100644 --- a/yudao-admin-ui/src/api/login.js +++ b/yudao-admin-ui/src/api/login.js @@ -74,3 +74,28 @@ export function socialLogin2(type, code, state, username, password) { } }) } + +// 社交绑定,使用 code 授权码 +export function socialBind(type, code, state) { + return request({ + url: '/social-bind', + method: 'post', + data: { + type, + code, + state, + } + }) +} + +// 取消社交绑定 +export function socialUnbind(type, unionId) { + return request({ + url: '/social-unbind', + method: 'delete', + data: { + type, + unionId + } + }) +} diff --git a/yudao-admin-ui/src/views/socialLogin.vue b/yudao-admin-ui/src/views/socialLogin.vue index 210eae382..6f8aee945 100644 --- a/yudao-admin-ui/src/views/socialLogin.vue +++ b/yudao-admin-ui/src/views/socialLogin.vue @@ -69,7 +69,6 @@ export default { this.getCookie(); // 重定向地址 this.redirect = this.$route.query.redirect; - debugger // 社交登录相关 this.type = this.$route.query.type; this.code = this.$route.query.code; diff --git a/yudao-admin-ui/src/views/system/user/profile/index.vue b/yudao-admin-ui/src/views/system/user/profile/index.vue index bb4192857..20c37f99c 100644 --- a/yudao-admin-ui/src/views/system/user/profile/index.vue +++ b/yudao-admin-ui/src/views/system/user/profile/index.vue @@ -33,7 +33,7 @@