master
kira 6 years ago
commit 1ac4662220

@ -22,6 +22,7 @@ public class CityPartnerBean {
@NotBlank(message = "error.payment.valid.param_missing") @NotBlank(message = "error.payment.valid.param_missing")
@Length(max = 30) @Length(max = 30)
private String phone; private String phone;
private String captcha;
public JSONObject toJSON(){ public JSONObject toJSON(){
return (JSONObject) JSONObject.toJSON(this); return (JSONObject) JSONObject.toJSON(this);
@ -58,4 +59,12 @@ public class CityPartnerBean {
public void setPhone(String phone) { public void setPhone(String phone) {
this.phone = phone; this.phone = phone;
} }
public String getCaptcha() {
return captcha;
}
public void setCaptcha(String captcha) {
this.captcha = captcha;
}
} }

@ -1,16 +1,14 @@
package au.com.royalpay.payment.manage.citypartner.web; package au.com.royalpay.payment.manage.citypartner.web;
import au.com.royalpay.payment.manage.citypartner.beans.CityPartnerBean; import au.com.royalpay.payment.manage.citypartner.beans.CityPartnerBean;
import au.com.royalpay.payment.manage.citypartner.core.CityPartnerRegisterService; import au.com.royalpay.payment.manage.citypartner.core.CityPartnerRegisterService;
import au.com.royalpay.payment.tools.exceptions.ForbiddenException; import au.com.royalpay.payment.manage.merchants.core.ClientApply;
import au.com.royalpay.payment.tools.CommonConsts;
import au.com.royalpay.payment.tools.http.HttpUtils; import au.com.royalpay.payment.tools.http.HttpUtils;
import org.springframework.validation.Errors; import org.springframework.validation.Errors;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid; import javax.validation.Valid;
/** /**
@ -21,13 +19,23 @@ import javax.validation.Valid;
public class CityPartnerRegisterController { public class CityPartnerRegisterController {
@Resource @Resource
private CityPartnerRegisterService cityPartnerRegisterService; private CityPartnerRegisterService cityPartnerRegisterService;
@Resource
private ClientApply clientApply;
@RequestMapping(method = RequestMethod.POST) @RequestMapping(method = RequestMethod.POST)
public void register(@RequestBody @Valid CityPartnerBean partner, Errors errors) { public void register(@CookieValue(CommonConsts.CODE_KEY) String codeKey, HttpServletResponse response,
HttpUtils.handleValidErrors(errors); @RequestBody @Valid CityPartnerBean partner, Errors errors) throws Exception{
if (true) { String codeValue = clientApply.getVerifyCode(codeKey);
throw new ForbiddenException(); if (codeValue == null) {
throw new Exception("Verification code has expired");
} }
if (!codeValue.equals(partner.getCaptcha())){
throw new Exception("Verification code is not correct");
}else {
clientApply.deleteVerifyCodeKey(codeKey);
HttpUtils.dropCookie(response, CommonConsts.CODE_KEY);
}
HttpUtils.handleValidErrors(errors);
cityPartnerRegisterService.saveRegistry(partner); cityPartnerRegisterService.saveRegistry(partner);
} }
} }

@ -139,13 +139,17 @@
}, },
error: function (jqXHR) { error: function (jqXHR) {
alert(JSON.parse(jqXHR.responseText).message); alert(JSON.parse(jqXHR.responseText).message);
$submit.removeAttr('disabled') $("#kaptcha").attr("src", "/partners/application/captcha-image?" + Math.floor(Math.random() * 100));
$submit.removeAttr('disabled');
} }
}); });
$submit.attr('disabled', 'disabled'); $submit.attr('disabled', 'disabled');
return false; return false;
}) });
}) $('#kaptcha').click(function () {
$(this).attr("src", "/partners/application/captcha-image?" + Math.floor(Math.random() * 100));
});
});
</script> </script>
<script> <script>
var _hmt = _hmt || []; var _hmt = _hmt || [];
@ -185,6 +189,13 @@
<input class="form-control input-lg" name="phone" type="tel" id="phone-input" maxlength="30" <input class="form-control input-lg" name="phone" type="tel" id="phone-input" maxlength="30"
required> required>
</div> </div>
<label class="control-label" for="captcha">验证码 Identifying Code</label>
<div class="form-group">
<input class="form-control input-lg" name="captcha" type="text" id="captcha" maxlength="30" style="width: 80%;display: inline"
required>
<img style="width:20%;display:inline;height: 46px;float: right" id="kaptcha" src="/partners/application/captcha-image"
title="点击更换">
</div>
<div class="form-group"> <div class="form-group">
<button class="submit-btn" type="submit">提交 Submit</button> <button class="submit-btn" type="submit">提交 Submit</button>
</div> </div>

Loading…
Cancel
Save