Commit 65abc667b03086fe321fe13f0149fad61058a994
1 parent
8aa45406
code review 社交登陆相关的代码
Showing
6 changed files
with
13 additions
and
11 deletions
yudao-admin-server/src/main/java/cn/iocoder/yudao/adminserver/modules/system/controller/auth/SysAuthController.java
| ... | ... | @@ -50,7 +50,7 @@ public class SysAuthController { |
| 50 | 50 | @Resource |
| 51 | 51 | private SysPermissionService permissionService; |
| 52 | 52 | @Resource |
| 53 | - private SysSocialCoreService socialService; | |
| 53 | + private SysSocialCoreService socialCoreService; | |
| 54 | 54 | |
| 55 | 55 | @PostMapping("/login") |
| 56 | 56 | @ApiOperation("使用账号密码登录") |
| ... | ... | @@ -102,7 +102,7 @@ public class SysAuthController { |
| 102 | 102 | }) |
| 103 | 103 | public CommonResult<String> socialAuthRedirect(@RequestParam("type") Integer type, |
| 104 | 104 | @RequestParam("redirectUri") String redirectUri) { |
| 105 | - return CommonResult.success(socialService.getAuthorizeUrl(type, redirectUri)); | |
| 105 | + return CommonResult.success(socialCoreService.getAuthorizeUrl(type, redirectUri)); | |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | @PostMapping("/social-login") |
| ... | ... | @@ -133,7 +133,7 @@ public class SysAuthController { |
| 133 | 133 | @DeleteMapping("/social-unbind") |
| 134 | 134 | @ApiOperation("取消社交绑定") |
| 135 | 135 | public CommonResult<Boolean> socialUnbind(@RequestBody SysAuthSocialUnbindReqVO reqVO) { |
| 136 | - socialService.unbindSocialUser(getLoginUserId(), reqVO.getType(), reqVO.getUnionId(), UserTypeEnum.ADMIN); | |
| 136 | + socialCoreService.unbindSocialUser(getLoginUserId(), reqVO.getType(), reqVO.getUnionId(), UserTypeEnum.ADMIN); | |
| 137 | 137 | return CommonResult.success(true); |
| 138 | 138 | } |
| 139 | 139 | ... | ... |
yudao-framework/yudao-spring-boot-starter-biz-social/src/main/java/cn/iocoder/yudao/framework/social/core/YudaoAuthRequestFactory.java
| 1 | 1 | package cn.iocoder.yudao.framework.social.core; |
| 2 | 2 | |
| 3 | 3 | import cn.hutool.core.util.EnumUtil; |
| 4 | -import cn.hutool.core.util.StrUtil; | |
| 5 | 4 | import cn.iocoder.yudao.framework.social.core.enums.AuthExtendSource; |
| 6 | 5 | import cn.iocoder.yudao.framework.social.core.request.AuthWeChatMiniProgramRequest; |
| 7 | 6 | import com.xkcoding.http.config.HttpConfig; |
| ... | ... | @@ -18,12 +17,14 @@ import java.net.Proxy; |
| 18 | 17 | import java.util.Map; |
| 19 | 18 | |
| 20 | 19 | /** |
| 21 | - * 第三方授权拓展request工厂类 | |
| 20 | + * 第三方授权拓展 request 工厂类 | |
| 21 | + * TODO @timfruit 可以说明下,为啥有了 AuthRequestFactory 类,咱还需要自定义 | |
| 22 | 22 | * |
| 23 | 23 | * @author timfruit |
| 24 | 24 | * @date 2021-10-31 |
| 25 | 25 | */ |
| 26 | 26 | public class YudaoAuthRequestFactory extends AuthRequestFactory { |
| 27 | + | |
| 27 | 28 | protected JustAuthProperties properties; |
| 28 | 29 | protected AuthStateCache authStateCache; |
| 29 | 30 | |
| ... | ... | @@ -34,7 +35,7 @@ public class YudaoAuthRequestFactory extends AuthRequestFactory { |
| 34 | 35 | } |
| 35 | 36 | |
| 36 | 37 | /** |
| 37 | - * 返回AuthRequest对象 | |
| 38 | + * 返回 AuthRequest 对象 | |
| 38 | 39 | * |
| 39 | 40 | * @param source {@link AuthSource} |
| 40 | 41 | * @return {@link AuthRequest} |
| ... | ... | @@ -86,6 +87,7 @@ public class YudaoAuthRequestFactory extends AuthRequestFactory { |
| 86 | 87 | * @param authConfig {@link AuthConfig} |
| 87 | 88 | */ |
| 88 | 89 | protected void configureHttpConfig(String authSource, AuthConfig authConfig, JustAuthProperties.JustAuthHttpConfig httpConfig) { |
| 90 | + // TODO @timfruit:可以改成反射调用父类的方法。可能有一定的损耗,但是可以忽略不计的 | |
| 89 | 91 | if (null == httpConfig) { |
| 90 | 92 | return; |
| 91 | 93 | } | ... | ... |
yudao-framework/yudao-spring-boot-starter-biz-social/src/main/java/cn/iocoder/yudao/framework/social/core/enums/AuthExtendSource.java
| ... | ... | @@ -2,6 +2,7 @@ package cn.iocoder.yudao.framework.social.core.enums; |
| 2 | 2 | |
| 3 | 3 | import me.zhyd.oauth.config.AuthSource; |
| 4 | 4 | |
| 5 | +// TODO @timfruit:类注释 | |
| 5 | 6 | public enum AuthExtendSource implements AuthSource { |
| 6 | 7 | |
| 7 | 8 | /** |
| ... | ... | @@ -28,6 +29,4 @@ public enum AuthExtendSource implements AuthSource { |
| 28 | 29 | } |
| 29 | 30 | } |
| 30 | 31 | |
| 31 | - ; | |
| 32 | - | |
| 33 | 32 | } | ... | ... |
yudao-framework/yudao-spring-boot-starter-biz-social/src/main/java/cn/iocoder/yudao/framework/social/core/model/AuthExtendToken.java
| ... | ... | @@ -4,7 +4,7 @@ import lombok.*; |
| 4 | 4 | import me.zhyd.oauth.model.AuthToken; |
| 5 | 5 | |
| 6 | 6 | /** |
| 7 | - * 授权所需的token 拓展类 | |
| 7 | + * 授权所需的 token 拓展类 | |
| 8 | 8 | * |
| 9 | 9 | * @author timfruit |
| 10 | 10 | * @date 2021-10-29 |
| ... | ... | @@ -16,7 +16,7 @@ import me.zhyd.oauth.model.AuthToken; |
| 16 | 16 | public class AuthExtendToken extends AuthToken { |
| 17 | 17 | |
| 18 | 18 | /** |
| 19 | - * 微信小程序 会话密钥 | |
| 19 | + * 微信小程序 - 会话密钥 | |
| 20 | 20 | */ |
| 21 | 21 | private String miniSessionKey; |
| 22 | 22 | ... | ... |
yudao-framework/yudao-spring-boot-starter-biz-social/src/main/java/cn/iocoder/yudao/framework/social/core/request/AuthWeChatMiniProgramRequest.java
yudao-user-server/src/main/java/cn/iocoder/yudao/userserver/modules/system/service/auth/impl/SysAuthServiceImpl.java
| ... | ... | @@ -65,7 +65,7 @@ public class SysAuthServiceImpl implements SysAuthService { |
| 65 | 65 | private SysUserSessionCoreService userSessionCoreService; |
| 66 | 66 | @Resource |
| 67 | 67 | private SysSocialCoreService socialService; |
| 68 | - private static final UserTypeEnum USER_TYPE_ENUM = UserTypeEnum.MEMBER; | |
| 68 | + private static final UserTypeEnum USER_TYPE_ENUM = UserTypeEnum.MEMBER; // TODO @timfruit 挪到类的最前面。一般是 静态变量,到成员变量的顺序。 | |
| 69 | 69 | |
| 70 | 70 | @Override |
| 71 | 71 | public UserDetails loadUserByUsername(String mobile) throws UsernameNotFoundException { | ... | ... |