code review 社交登陆相关的代码

pull/2/head
YunaiV 2021-11-02 08:12:37 +08:00
parent 8aa45406fd
commit 65abc667b0
6 changed files with 13 additions and 11 deletions

View File

@ -50,7 +50,7 @@ public class SysAuthController {
@Resource
private SysPermissionService permissionService;
@Resource
private SysSocialCoreService socialService;
private SysSocialCoreService socialCoreService;
@PostMapping("/login")
@ApiOperation("使用账号密码登录")
@ -102,7 +102,7 @@ public class SysAuthController {
})
public CommonResult<String> socialAuthRedirect(@RequestParam("type") Integer type,
@RequestParam("redirectUri") String redirectUri) {
return CommonResult.success(socialService.getAuthorizeUrl(type, redirectUri));
return CommonResult.success(socialCoreService.getAuthorizeUrl(type, redirectUri));
}
@PostMapping("/social-login")
@ -133,7 +133,7 @@ public class SysAuthController {
@DeleteMapping("/social-unbind")
@ApiOperation("取消社交绑定")
public CommonResult<Boolean> socialUnbind(@RequestBody SysAuthSocialUnbindReqVO reqVO) {
socialService.unbindSocialUser(getLoginUserId(), reqVO.getType(), reqVO.getUnionId(), UserTypeEnum.ADMIN);
socialCoreService.unbindSocialUser(getLoginUserId(), reqVO.getType(), reqVO.getUnionId(), UserTypeEnum.ADMIN);
return CommonResult.success(true);
}

View File

@ -1,7 +1,6 @@
package cn.iocoder.yudao.framework.social.core;
import cn.hutool.core.util.EnumUtil;
import cn.hutool.core.util.StrUtil;
import cn.iocoder.yudao.framework.social.core.enums.AuthExtendSource;
import cn.iocoder.yudao.framework.social.core.request.AuthWeChatMiniProgramRequest;
import com.xkcoding.http.config.HttpConfig;
@ -18,12 +17,14 @@ import java.net.Proxy;
import java.util.Map;
/**
* request
* request
* TODO @timfruit AuthRequestFactory
*
* @author timfruit
* @date 2021-10-31
*/
public class YudaoAuthRequestFactory extends AuthRequestFactory {
protected JustAuthProperties properties;
protected AuthStateCache authStateCache;
@ -34,7 +35,7 @@ public class YudaoAuthRequestFactory extends AuthRequestFactory {
}
/**
* AuthRequest
* AuthRequest
*
* @param source {@link AuthSource}
* @return {@link AuthRequest}
@ -86,6 +87,7 @@ public class YudaoAuthRequestFactory extends AuthRequestFactory {
* @param authConfig {@link AuthConfig}
*/
protected void configureHttpConfig(String authSource, AuthConfig authConfig, JustAuthProperties.JustAuthHttpConfig httpConfig) {
// TODO @timfruit可以改成反射调用父类的方法。可能有一定的损耗但是可以忽略不计的
if (null == httpConfig) {
return;
}

View File

@ -2,6 +2,7 @@ package cn.iocoder.yudao.framework.social.core.enums;
import me.zhyd.oauth.config.AuthSource;
// TODO @timfruit类注释
public enum AuthExtendSource implements AuthSource {
/**
@ -28,6 +29,4 @@ public enum AuthExtendSource implements AuthSource {
}
}
;
}

View File

@ -4,7 +4,7 @@ import lombok.*;
import me.zhyd.oauth.model.AuthToken;
/**
* token
* token
*
* @author timfruit
* @date 2021-10-29
@ -16,7 +16,7 @@ import me.zhyd.oauth.model.AuthToken;
public class AuthExtendToken extends AuthToken {
/**
*
* -
*/
private String miniSessionKey;

View File

@ -86,6 +86,7 @@ public class AuthWeChatMiniProgramRequest extends AuthDefaultRequest {
.build();
}
// TODO @timfruit我们要采用驼峰的命名方式。不匹配的可以通过 jackson 的自定义注解映射
@Data
private static class CodeSessionResponse {
private int errcode;

View File

@ -65,7 +65,7 @@ public class SysAuthServiceImpl implements SysAuthService {
private SysUserSessionCoreService userSessionCoreService;
@Resource
private SysSocialCoreService socialService;
private static final UserTypeEnum USER_TYPE_ENUM = UserTypeEnum.MEMBER;
private static final UserTypeEnum USER_TYPE_ENUM = UserTypeEnum.MEMBER; // TODO @timfruit 挪到类的最前面。一般是 静态变量,到成员变量的顺序。
@Override
public UserDetails loadUserByUsername(String mobile) throws UsernameNotFoundException {