添加第三方登录,判断是否为当前用户信息

This commit is contained in:
pikachu1995@126.com
2023-03-10 06:46:21 +08:00
parent 0261b7e9ab
commit 606f9d2ccf
2 changed files with 12 additions and 2 deletions

View File

@@ -188,7 +188,7 @@ public class ConnectServiceImpl extends ServiceImpl<ConnectMapper, Connect> impl
connectAuthUser.setUsername("m" + phone);
connectAuthUser.setPhone(phone);
AuthToken authToken=new AuthToken();
AuthToken authToken = new AuthToken();
authToken.setUnionId(unionId);
connectAuthUser.setToken(authToken);
return this.unionLoginCallback(connectAuthUser, true);
@@ -227,9 +227,14 @@ public class ConnectServiceImpl extends ServiceImpl<ConnectMapper, Connect> impl
Connect connect = this.queryConnect(
ConnectQueryDTO.builder().unionId(unionId).unionType(type).build()
);
//如果未绑定则直接绑定
if (connect == null) {
connect = new Connect(userId, unionId, type);
this.save(connect);
//如果已绑定不是当前用户信息则删除绑定信息,重新绑定
} else if (!connect.getUserId().equals(userId)) {
this.removeById(connect.getId());
this.loginBindUser(userId, unionId, type);
}
}