刪除ip限定

master
duLingLing 5 years ago
parent 0db2b3a576
commit ac6f9877e1

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

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

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

Loading…
Cancel
Save