code review 社交登陆相关的代码
parent
8aa45406fd
commit
65abc667b0
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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 {
|
|||
}
|
||||
}
|
||||
|
||||
;
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -86,6 +86,7 @@ public class AuthWeChatMiniProgramRequest extends AuthDefaultRequest {
|
|||
.build();
|
||||
}
|
||||
|
||||
// TODO @timfruit:我们要采用驼峰的命名方式。不匹配的,可以通过 jackson 的自定义注解映射
|
||||
@Data
|
||||
private static class CodeSessionResponse {
|
||||
private int errcode;
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue