|
@@ -4,8 +4,6 @@ import com.alibaba.fastjson.JSONObject;
|
|
import com.caimei365.user.components.WeChatService;
|
|
import com.caimei365.user.components.WeChatService;
|
|
import com.caimei365.user.mapper.LoginMapper;
|
|
import com.caimei365.user.mapper.LoginMapper;
|
|
import com.caimei365.user.model.ResponseJson;
|
|
import com.caimei365.user.model.ResponseJson;
|
|
-import com.caimei365.user.model.po.OperationPo;
|
|
|
|
-import com.caimei365.user.model.po.UserPo;
|
|
|
|
import com.caimei365.user.model.vo.UserLoginVo;
|
|
import com.caimei365.user.model.vo.UserLoginVo;
|
|
import com.caimei365.user.service.LoginService;
|
|
import com.caimei365.user.service.LoginService;
|
|
import com.caimei365.user.components.RedisService;
|
|
import com.caimei365.user.components.RedisService;
|
|
@@ -13,8 +11,8 @@ import com.caimei365.user.utils.JwtUtil;
|
|
import com.caimei365.user.utils.Md5Util;
|
|
import com.caimei365.user.utils.Md5Util;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.apache.commons.lang.StringUtils;
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
|
+import org.springframework.http.HttpHeaders;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
-import org.springframework.web.server.ServerWebExchange;
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
@@ -47,10 +45,10 @@ public class LoginServiceImpl implements LoginService {
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
public ResponseJson<UserLoginVo> passwordLogin(String mobileOrEmail, String password) {
|
|
public ResponseJson<UserLoginVo> passwordLogin(String mobileOrEmail, String password) {
|
|
- if (mobileOrEmail.isEmpty()) {
|
|
|
|
|
|
+ if (StringUtils.isBlank(mobileOrEmail)) {
|
|
return ResponseJson.error("请填写账户名", null);
|
|
return ResponseJson.error("请填写账户名", null);
|
|
}
|
|
}
|
|
- if (password.isEmpty()) {
|
|
|
|
|
|
+ if (StringUtils.isBlank(password)) {
|
|
return ResponseJson.error("请填写密码", null);
|
|
return ResponseJson.error("请填写密码", null);
|
|
}
|
|
}
|
|
//处理比对密码
|
|
//处理比对密码
|
|
@@ -77,15 +75,15 @@ public class LoginServiceImpl implements LoginService {
|
|
* @param code 微信授权code
|
|
* @param code 微信授权code
|
|
* @param encryptedData 微信加密数据
|
|
* @param encryptedData 微信加密数据
|
|
* @param iv 加密算法的初始向量
|
|
* @param iv 加密算法的初始向量
|
|
- * @param serverWebExchange ServerWebExchange
|
|
|
|
|
|
+ * @param headers HttpHeaders
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
- public ResponseJson<UserLoginVo> appletsAuthorization(String code, String encryptedData, String iv, ServerWebExchange serverWebExchange) {
|
|
|
|
|
|
+ public ResponseJson<UserLoginVo> appletsAuthorization(String code, String encryptedData, String iv, HttpHeaders headers) {
|
|
if (StringUtils.isBlank(code)) {
|
|
if (StringUtils.isBlank(code)) {
|
|
return ResponseJson.error("没有获取到微信授权code", null);
|
|
return ResponseJson.error("没有获取到微信授权code", null);
|
|
}
|
|
}
|
|
// 小程序微信授权获取登录信息
|
|
// 小程序微信授权获取登录信息
|
|
- ResponseJson<Map<String, Object>> appletsInfo = weChatService.getInfoMapByApplets(code, serverWebExchange);
|
|
|
|
|
|
+ ResponseJson<Map<String, Object>> appletsInfo = weChatService.getInfoMapByApplets(code, headers);
|
|
if (appletsInfo.getCode() == -1) {
|
|
if (appletsInfo.getCode() == -1) {
|
|
return ResponseJson.error(appletsInfo.getMsg(), null);
|
|
return ResponseJson.error(appletsInfo.getMsg(), null);
|
|
}
|
|
}
|
|
@@ -146,10 +144,10 @@ public class LoginServiceImpl implements LoginService {
|
|
* @param code 微信code
|
|
* @param code 微信code
|
|
* @param state 安全认证
|
|
* @param state 安全认证
|
|
* @param mode 1:静默授权,2:用户手动授权
|
|
* @param mode 1:静默授权,2:用户手动授权
|
|
- * @param serverWebExchange ServerWebExchange
|
|
|
|
|
|
+ * @param headers HttpHeaders
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
- public ResponseJson<UserLoginVo> websiteAuthorization(String code, String state, Integer mode, ServerWebExchange serverWebExchange) {
|
|
|
|
|
|
+ public ResponseJson<UserLoginVo> websiteAuthorization(String code, String state, Integer mode, HttpHeaders headers) {
|
|
if (StringUtils.isBlank(code) || StringUtils.isBlank(state)) {
|
|
if (StringUtils.isBlank(code) || StringUtils.isBlank(state)) {
|
|
return ResponseJson.error("参数异常", null);
|
|
return ResponseJson.error("参数异常", null);
|
|
}
|
|
}
|
|
@@ -254,7 +252,7 @@ public class LoginServiceImpl implements LoginService {
|
|
* @param state 安全认证
|
|
* @param state 安全认证
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
- public void qrCodeAuthorization(String code, String state, ServerWebExchange serverWebExchange) {
|
|
|
|
|
|
+ public void qrCodeAuthorization(String code, String state) {
|
|
Map<String, Object> map = new HashMap<>();
|
|
Map<String, Object> map = new HashMap<>();
|
|
// 简单验证,防止csrf攻击(跨站请求伪造攻击)
|
|
// 简单验证,防止csrf攻击(跨站请求伪造攻击)
|
|
String stateCache = (String) redisService.get("state:" + state);
|
|
String stateCache = (String) redisService.get("state:" + state);
|