From e86765c6bc716f566738d7b2d9e309cbd5b25e87 Mon Sep 17 00:00:00 2001 From: 疯狂的狮子Li <15040126243@163.com> Date: 星期五, 28 七月 2023 13:53:05 +0800 Subject: [PATCH] * update springboot 3.0.8 => 3.1.2 * update spring-mybatis 3.0.1 => 3.0.2 * update easyexcel 3.3.1 => 3.3.2 * update hutool 5.8.18 => 5.8.20 * update redisson 3.20.1 => 3.23.1 * update dynamic-ds 4.1.1 => 4.1.2 * update mapstruct-plus 1.3.1 => 1.3.5 * update aws-java-sdk-s3 1.12.400 => 1.12.517 * update maven-surefire-plugin 3.0.0 => 3.1.2 --- ruoyi-admin/src/main/java/org/dromara/web/controller/AuthController.java | 38 ++++++++++++++++---------------------- 1 files changed, 16 insertions(+), 22 deletions(-) diff --git a/ruoyi-admin/src/main/java/org/dromara/web/controller/AuthController.java b/ruoyi-admin/src/main/java/org/dromara/web/controller/AuthController.java index 9032d27..3c03e42 100644 --- a/ruoyi-admin/src/main/java/org/dromara/web/controller/AuthController.java +++ b/ruoyi-admin/src/main/java/org/dromara/web/controller/AuthController.java @@ -6,7 +6,6 @@ import jakarta.servlet.http.HttpServletRequest; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import me.zhyd.oauth.model.AuthCallback; import me.zhyd.oauth.model.AuthResponse; import me.zhyd.oauth.model.AuthUser; import me.zhyd.oauth.request.AuthRequest; @@ -87,7 +86,7 @@ } /** - * 璁よ瘉鎺堟潈 + * 绗笁鏂圭櫥褰曡姹� * * @param source 鐧诲綍鏉ユ簮 * @return 缁撴灉 @@ -98,36 +97,31 @@ if (ObjectUtil.isNull(obj)) { return R.fail(source + "骞冲彴璐﹀彿鏆備笉鏀寔"); } - AuthRequest authRequest = SocialUtils.getAuthRequest(source, - obj.getClientId(), - obj.getClientSecret(), - obj.getRedirectUri()); + AuthRequest authRequest = SocialUtils.getAuthRequest(source, socialProperties); String authorizeUrl = authRequest.authorize(AuthStateUtils.createState()); - return R.ok(authorizeUrl); + return R.ok("鎿嶄綔鎴愬姛", authorizeUrl); } /** - * 绗笁鏂圭櫥褰曞洖璋冧笟鍔″鐞� + * 绗笁鏂圭櫥褰曞洖璋冧笟鍔″鐞� 缁戝畾鎺堟潈 * - * @param source 鐧诲綍鏉ユ簮 - * @param callback 鎺堟潈鍝嶅簲瀹炰綋 + * @param loginBody 璇锋眰浣� * @return 缁撴灉 */ - @SuppressWarnings("unchecked") - @GetMapping("/social-login") - public R<String> socialLogin(String source, AuthCallback callback) { - SocialLoginConfigProperties obj = socialProperties.getType().get(source); - if (ObjectUtil.isNull(obj)) { - return R.fail(source + "骞冲彴璐﹀彿鏆備笉鏀寔"); + @PostMapping("/social/callback") + public R<Void> socialCallback(@RequestBody LoginBody loginBody) { + // 鑾峰彇绗笁鏂圭櫥褰曚俊鎭� + AuthResponse<AuthUser> response = SocialUtils.loginAuth(loginBody, socialProperties); + AuthUser authUserData = response.getData(); + // 鍒ゆ柇鎺堟潈鍝嶅簲鏄惁鎴愬姛 + if (!response.ok()) { + return R.fail(response.getMsg()); } - AuthRequest authRequest = SocialUtils.getAuthRequest(source, - obj.getClientId(), - obj.getClientSecret(), - obj.getRedirectUri()); - AuthResponse<AuthUser> response = authRequest.login(callback); - return loginService.socialLogin(source, response); + loginService.socialRegister(authUserData); + return R.ok(); } + /** * 鍙栨秷鎺堟潈 * -- Gitblit v1.9.3