From ba86c37ae8112d583f7026b7f0822d88cd56d554 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=89=E6=9D=A5=E6=8A=80=E6=9C=AF?= <1490493387@qq.com> Date: Sun, 10 Oct 2021 01:55:02 +0800 Subject: [PATCH] =?UTF-8?q?style:=E4=BB=A3=E7=A0=81=E7=A7=BB=E9=99=A4?= =?UTF-8?q?=E6=97=A0=E7=94=A8=E4=BE=9D=E8=B5=96=E5=92=8C=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E5=A4=9A=E4=BD=99=E7=A9=BA=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/service/impl/AliyunSmsServiceImpl.java | 15 ++++++++++----- .../extension/wechat/WechatTokenGranter.java | 2 -- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/youlai-admin/admin-boot/src/main/java/com/youlai/admin/service/impl/AliyunSmsServiceImpl.java b/youlai-admin/admin-boot/src/main/java/com/youlai/admin/service/impl/AliyunSmsServiceImpl.java index 7d414afa3..ee99520c3 100644 --- a/youlai-admin/admin-boot/src/main/java/com/youlai/admin/service/impl/AliyunSmsServiceImpl.java +++ b/youlai-admin/admin-boot/src/main/java/com/youlai/admin/service/impl/AliyunSmsServiceImpl.java @@ -2,7 +2,6 @@ package com.youlai.admin.service.impl; import cn.hutool.core.util.RandomUtil; import cn.hutool.json.JSONUtil; -import com.alibaba.fastjson.JSON; import com.aliyuncs.CommonRequest; import com.aliyuncs.CommonResponse; import com.aliyuncs.DefaultAcsClient; @@ -34,7 +33,6 @@ import java.util.concurrent.TimeUnit; @RequiredArgsConstructor public class AliyunSmsServiceImpl implements ISmsService { - @Setter private String accessKeyId; @@ -53,12 +51,11 @@ public class AliyunSmsServiceImpl implements ISmsService { @Setter private String signName; - private final StringRedisTemplate stringRedisTemplate; /** - * 发送短信 + * 发送验证码短信 * * @param phoneNumber 手机号 * @return @@ -66,11 +63,19 @@ public class AliyunSmsServiceImpl implements ISmsService { @Override public boolean sendSmsCode(String phoneNumber) { String code = RandomUtil.randomNumbers(6); // 随机生成6位的手机验证码 - stringRedisTemplate.opsForValue().set(AuthConstants.SMS_CODE_PREFIX + phoneNumber, code, 600, TimeUnit.SECONDS); + stringRedisTemplate.opsForValue().set(AuthConstants.SMS_CODE_PREFIX + phoneNumber, code, 600, TimeUnit.SECONDS); // 验证登录成功之后删除 boolean result = this.sendSms(phoneNumber, code); return result; } + + /** + * 发送短信 + * + * @param phoneNumbers 手机号,多个用英文逗号(,)分割 + * @param code + * @return + */ private boolean sendSms(String phoneNumbers, String code) { DefaultProfile profile = DefaultProfile.getProfile(regionId, accessKeyId, accessKeySecret); IAcsClient client = new DefaultAcsClient(profile); diff --git a/youlai-auth/src/main/java/com/youlai/auth/security/extension/wechat/WechatTokenGranter.java b/youlai-auth/src/main/java/com/youlai/auth/security/extension/wechat/WechatTokenGranter.java index 5a07837f5..864ddee46 100644 --- a/youlai-auth/src/main/java/com/youlai/auth/security/extension/wechat/WechatTokenGranter.java +++ b/youlai-auth/src/main/java/com/youlai/auth/security/extension/wechat/WechatTokenGranter.java @@ -1,6 +1,5 @@ package com.youlai.auth.security.extension.wechat; -import cn.hutool.json.JSONUtil; import org.springframework.security.authentication.*; import org.springframework.security.core.Authentication; import org.springframework.security.oauth2.common.exceptions.InvalidGrantException; @@ -33,7 +32,6 @@ public class WechatTokenGranter extends AbstractTokenGranter { String encryptedData = parameters.get("encryptedData"); String iv = parameters.get("iv"); - parameters.remove("code"); parameters.remove("encryptedData"); parameters.remove("iv");