add verify mail & SMS code

master
wangning 7 years ago
parent 1842e10bb3
commit 15fe2c59fb

@ -151,7 +151,7 @@ public class SimpleClientApplyServiceImpl implements SimpleClientApplyService {
if(StringUtils.isNotEmpty(codeKey)){
String redisAddress = stringRedisTemplate.boundValueOps(getVerifyMailRedisKey(codeKey)).get();
if(!address.equals(redisAddress)){
throw new BadRequestException("Data error");
throw new BadRequestException("Mail expired");
}else {
return codeKey;
}

@ -2,6 +2,8 @@ package au.com.royalpay.payment.manage.application.web;
import au.com.royalpay.payment.manage.application.core.SimpleClientApplyService;
import au.com.royalpay.payment.manage.merchants.beans.NewAccountBean;
import au.com.royalpay.payment.manage.signin.beans.LoginInfo;
import au.com.royalpay.payment.manage.signin.core.SignInAccountService;
import au.com.royalpay.payment.tools.CommonConsts;
import au.com.royalpay.payment.tools.http.HttpUtils;
@ -26,7 +28,7 @@ public class SimpleClientApplyController {
@Resource
private SimpleClientApplyService simpleClientApplyService;
@Resource
private SignInAccountService signInAccountService;
@RequestMapping(value = "/account/{codeKey}", method = RequestMethod.POST)
@ResponseBody
public void registerAccount(@PathVariable String codeKey, @RequestBody @Valid NewAccountBean accountBean, Errors errors, HttpServletResponse response)
@ -45,6 +47,7 @@ public class SimpleClientApplyController {
simpleClientApplyService.checkOrGenerateVerifyMailKey(address,codeKey);
ModelAndView view = new ModelAndView("verify_mail");
view.addObject("codeKey", codeKey);
view.addObject("address", address);
return view;
}
@ -52,10 +55,10 @@ public class SimpleClientApplyController {
@ResponseBody
public void verifyMail(@PathVariable String codeKey, @PathVariable String address,@RequestBody JSONObject account){
simpleClientApplyService.checkOrGenerateVerifyMailKey(address,codeKey);
ModelAndView view = new ModelAndView("verify_mail");
view.addObject("codeKey", codeKey);
LoginInfo loginInfo = new LoginInfo();
loginInfo.setLoginId(account.getString("userName"));
loginInfo.setPassword(account.getString("password"));
signInAccountService.accountCheck(loginInfo);
simpleClientApplyService.deleteVerifyMailKey(codeKey);
}
}

@ -17,6 +17,8 @@ public interface SignInAccountService {
JSONObject managerLoginCheck(LoginInfo loginInfo);
JSONObject accountCheck(LoginInfo loginInfo);
JSONObject clientLoginCheck(LoginInfo loginInfo);
void changeManagerPassword(JSONObject manager, ChangePwdBean change);

@ -166,6 +166,13 @@ public class SignInAccountServiceImpl implements SignInAccountService, Applicati
return account;
}
@Override
public JSONObject accountCheck(LoginInfo loginInfo) {
JSONObject account = managerMapper.findAvailableByLoginId(loginInfo.getLoginId());
validLoginInfo(loginInfo, account);
return account;
}
private void validLoginInfo(LoginInfo loginInfo, JSONObject account) {
if (account == null) {
throw new BadRequestException(LocaleSupport.localeMessage("error.login.password"));

@ -78,14 +78,19 @@
<span class="glyphicon glyphicon-user form-control-feedback"></span>
</div>
<div class="form-group has-feedback">
<input type="password" id="password" name="password" class="form-control" placeholder="password">
<span class="glyphicon glyphicon-user form-control-feedback"></span>
</div>
<div class="row">
<div class="form-group col-xs-12">
<!-- <div class="form-group col-xs-12">
<input type="text" name="codeKey" class="form-control" style="width: 70%;display: inline"
id="codeKey" placeholder="Verification Code">
<img style="width:30%;display:inline;height: 34px;float: right" id="email-kaptcha"
src="/global/userstatus/captcha-login"
title="点击更换"/>
</div>
</div>-->
<div class="col-xs-12 margin-bottom">
<button type="button" id="submitEmail-btn" class="btn btn-success btn-block btn-flat">Submit</button>
</div>
@ -105,6 +110,9 @@
<script src="static/lib/bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" data-th-inline="javascript">
$(document).ready(function () {
window.address = /*[[${address}]]*/'';
window.codeKey = /*[[${codeKey}]]*/'';
$('input').keypress(function (evt) {
if (evt.keyCode == 13) {
$('#login-btn').click();
@ -117,29 +125,29 @@
alert('请输入用户名');
return;
}
var verifyCode = $('#email—verifyCode').val();
if (verifyCode == null || verifyCode.length == 0) {
alert('请填写验证码');
var password = $('#password').val();
if (password == null || password.length == 0) {
alert('请填码');
return;
}
$("#bg").show();
$("#show").show();
$.ajax({
url: '/register/account/mail/'+,
method: 'GET',
url: '/register/account/mail/'+window.address+'/verify/'+window.codeKey,
method: 'post',
data: JSON.stringify({userName:userName, password: password}),
contentType: 'application/json',
dataType: 'text',
success: function (resp) {
$("#bg").hide();
$("#show").hide();
alert("Reset password email has send your mailbox:"+resp);
alert("Succes");
location.href = 'index.html'
},
error: function (jqXHR) {
$("#bg").hide();
$("#show").hide();
alert(JSON.parse(jqXHR.responseText).message);
$('#email-kaptcha').attr("src", "/global/userstatus/captcha-login?" + Math.floor(Math.random() * 100));
}
})
})

Loading…
Cancel
Save