刪除ip限定

master
duLingLing 5 years ago
parent 0db2b3a576
commit ac6f9877e1

@ -10,7 +10,7 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>manage</artifactId>
<version>1.2.62</version>
<version>1.2.63</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

@ -208,7 +208,7 @@ public class RetailValidationController implements ApplicationEventPublisherAwar
HttpUtils.handleValidErrors(errors);
JSONObject result = new JSONObject();
simpleClientApplyService.verifyLoginSMSCode(params.getString("verify_code"), contactPhone);
String signKey = signInStatusManager.getClientInfoByPhoneStatusKey(contactPhone, nationCode,RequestEnvironment.getClientIp());
String signKey = signInStatusManager.getClientInfoByPhoneStatusKey(contactPhone, nationCode);
if(signKey!=null){
JSONObject account = signInStatusManager.getCurrentClient(signKey);
account = JSON.parseObject(account.toJSONString());
@ -247,7 +247,7 @@ public class RetailValidationController implements ApplicationEventPublisherAwar
loginInfo.setLoginId(params.getString("loginId"));
loginInfo.setPassword(params.getString("password"));
String signKey = signInStatusManager.verifyClientAccountLogin(loginInfo,"phone");
signInStatusManager.verifyClientLoginPhoneBindCode(contactPhone,nationCode,RequestEnvironment.getClientIp());
signInStatusManager.verifyClientLoginPhoneBindCode(contactPhone,nationCode);
JSONObject account = signInStatusManager.getCurrentClient(signKey);
retailAppService.updateLoginClientAccountPhone(account, contactPhone,nationCode);
account.put("sign_key", signKey);
@ -271,7 +271,7 @@ public class RetailValidationController implements ApplicationEventPublisherAwar
public JSONObject clientAppWechatSignIn(@RequestBody JSONObject params,
Errors errors) {
HttpUtils.handleValidErrors(errors);
JSONObject account = signInStatusManager.clientAppWechatSignIn(params.getString("code"),RequestEnvironment.getClientIp());
JSONObject account = signInStatusManager.clientAppWechatSignIn(params.getString("code"));
if(!account.getBoolean("bind_status")){
deviceSupport.validDeviceWithClient(account, params.getString("app_openid"));
return account;
@ -287,7 +287,7 @@ public class RetailValidationController implements ApplicationEventPublisherAwar
*/
@PostMapping("/login/wechat_bind")
public JSONObject wechatLoginBind(@RequestBody JSONObject params){
JSONObject wechatInfo = signInStatusManager.verifyClientLoginWechatBindCode(params.getString("wechat_openid"),RequestEnvironment.getClientIp());
JSONObject wechatInfo = signInStatusManager.verifyClientLoginWechatBindCode(params.getString("wechat_openid"));
LoginInfo loginInfo = new LoginInfo();
loginInfo.setLoginId(params.getString("loginId"));
loginInfo.setPassword(params.getString("password"));

@ -73,7 +73,7 @@ public interface SignInStatusManager {
* @param code
* @return
*/
JSONObject clientAppWechatSignIn(String code,String ip);
JSONObject clientAppWechatSignIn(String code);
/**
*
@ -81,7 +81,7 @@ public interface SignInStatusManager {
* @param nationCode
* @return
*/
String getClientInfoByPhoneStatusKey(String phone,String nationCode,String ip);
String getClientInfoByPhoneStatusKey(String phone,String nationCode);
/**
*
@ -93,17 +93,15 @@ public interface SignInStatusManager {
/**
* openId
* @param codeId
* @param ip
* @return
*/
JSONObject verifyClientLoginWechatBindCode (String codeId,String ip);
JSONObject verifyClientLoginWechatBindCode (String codeId);
/**
*
* @param phone
* @param nationCode
* @param ip
* @return
*/
void verifyClientLoginPhoneBindCode (String phone,String nationCode,String ip);
void verifyClientLoginPhoneBindCode (String phone,String nationCode);
}

@ -82,12 +82,12 @@ public class SignInStatusManagerImpl implements SignInStatusManager {
}
@Override
public String getClientInfoByPhoneStatusKey(String phone, String nationCode,String ip) {
public String getClientInfoByPhoneStatusKey(String phone, String nationCode) {
String statusKey = newStatusKey();
JSONObject account = clientAccountMapper.findOneByPhoneAndCreateTimeDesc(phone, "+" + nationCode);
if (account == null) {
String expireMin = "5";
stringRedisTemplate.boundValueOps(getClientLoginPhoneBindRedisKey(phone,nationCode,ip)).set(phone, Long.parseLong(expireMin), TimeUnit.MINUTES);
stringRedisTemplate.boundValueOps(getClientLoginPhoneBindRedisKey(phone,nationCode)).set(phone, Long.parseLong(expireMin), TimeUnit.MINUTES);
return null;
}
stringRedisTemplate.boundValueOps(partnerLoginRedisKey(statusKey)).set(account.getString("account_id") + "", 30, TimeUnit.MINUTES);
@ -380,7 +380,7 @@ public class SignInStatusManagerImpl implements SignInStatusManager {
}
@Override
public JSONObject clientAppWechatSignIn(String code,String ip) {
public JSONObject clientAppWechatSignIn(String code) {
JSONObject user = mpClientAppWechatApiProvider.getApi("merchant-app").appLoginUser(code);
if(user==null){
throw new BadRequestException("WeChat users do not exist");
@ -396,7 +396,7 @@ public class SignInStatusManagerImpl implements SignInStatusManager {
res.put("app_openid", openId);
res.put("status", "success");
String expireMin = "5";
stringRedisTemplate.boundValueOps(getClientLoginWechatBindRedisKey(openId,ip)).set(openId+"&"+nickName+"&"+unionId, Long.parseLong(expireMin), TimeUnit.MINUTES);
stringRedisTemplate.boundValueOps(getClientLoginWechatBindRedisKey(openId)).set(openId+"&"+nickName+"&"+unionId, Long.parseLong(expireMin), TimeUnit.MINUTES);
return res;
}
String statusKey = newStatusKey();
@ -411,14 +411,14 @@ public class SignInStatusManagerImpl implements SignInStatusManager {
return result;
}
private String getClientLoginWechatBindRedisKey(String openId,String ip){
return "login:"+":"+CLIENT_LOGIN_WECHAT_BIND_PREFIX + "&"+openId+"&"+ip;
private String getClientLoginWechatBindRedisKey(String openId){
return "login:"+":"+CLIENT_LOGIN_WECHAT_BIND_PREFIX + "&"+openId;
}
@Override
public JSONObject verifyClientLoginWechatBindCode(String openId,String ip){
String rediskey = getClientLoginWechatBindRedisKey(openId,ip);
public JSONObject verifyClientLoginWechatBindCode(String openId){
String rediskey = getClientLoginWechatBindRedisKey(openId);
String codeValue = stringRedisTemplate.boundValueOps(rediskey).get();
if (codeValue == null || !codeValue.split("&")[0].equals(openId)) {
throw new BadRequestException("The WeChat ID does not apply for binding");
@ -432,12 +432,12 @@ public class SignInStatusManagerImpl implements SignInStatusManager {
}};
}
private String getClientLoginPhoneBindRedisKey(String phone,String nationCode,String ip){
return "login:"+CLIENT_LOGIN_PHONE_BIND_PREFIX + "&"+nationCode+"&"+phone+"&"+ip;
private String getClientLoginPhoneBindRedisKey(String phone,String nationCode){
return "login:"+CLIENT_LOGIN_PHONE_BIND_PREFIX + "&"+nationCode+"&"+phone;
}
public void verifyClientLoginPhoneBindCode(String phone,String nationCode,String ip){
String rediskey = getClientLoginPhoneBindRedisKey(phone,nationCode,ip);
public void verifyClientLoginPhoneBindCode(String phone,String nationCode){
String rediskey = getClientLoginPhoneBindRedisKey(phone,nationCode);
String codeValue = stringRedisTemplate.boundValueOps(rediskey).get();
if (codeValue == null || !codeValue.equals(phone)) {
throw new BadRequestException("The phone number is for application binding");

Loading…
Cancel
Save