Member:社交登录逻辑调整,如果登录时无用户,则自动创建用户,保持和各 App 统一逻辑

This commit is contained in:
YunaiV
2023-12-23 09:59:58 +08:00
parent 106c1ecf4c
commit d65c28d7f7
16 changed files with 80 additions and 38 deletions

View File

@ -158,7 +158,7 @@ public class AdminAuthServiceImpl implements AdminAuthService {
// 使用 code 授权码,进行登录。然后,获得到绑定的用户编号
SocialUserRespDTO socialUser = socialUserService.getSocialUser(UserTypeEnum.ADMIN.getValue(), reqVO.getType(),
reqVO.getCode(), reqVO.getState());
if (socialUser == null) {
if (socialUser == null || socialUser.getUserId() == null) {
throw exception(AUTH_THIRD_LOGIN_NOT_BIND);
}

View File

@ -99,13 +99,11 @@ public class SocialUserServiceImpl implements SocialUserService {
SocialUserDO socialUser = authSocialUser(socialType, userType, code, state);
Assert.notNull(socialUser, "社交用户不能为空");
// 如果未绑定的社交用户,则无法自动登录,进行报错
// 获得绑定用户
SocialUserBindDO socialUserBind = socialUserBindMapper.selectByUserTypeAndSocialUserId(userType,
socialUser.getId());
if (socialUserBind == null) {
throw exception(AUTH_THIRD_LOGIN_NOT_BIND);
}
return new SocialUserRespDTO(socialUser.getOpenid(), socialUserBind.getUserId());
return new SocialUserRespDTO(socialUser.getOpenid(), socialUser.getNickname(), socialUser.getAvatar(),
socialUserBind != null ? socialUserBind.getUserId() : null);
}
/**