Merge remote-tracking branch 'origin/clientApply' into clientApply

master
yuan 7 years ago
commit 5984216f64

@ -22,4 +22,5 @@ public interface SimpleClientApplyService {
void deleteVerifyMailKey(String codeKey); void deleteVerifyMailKey(String codeKey);
void checkAccountName(String acocunt_name);
} }

@ -1,18 +1,18 @@
package au.com.royalpay.payment.manage.application.core.impls; package au.com.royalpay.payment.manage.application.core.impls;
import au.com.royalpay.payment.manage.application.core.SimpleClientApplyService; import au.com.royalpay.payment.manage.application.core.SimpleClientApplyService;
import au.com.royalpay.payment.manage.mappers.system.ClientAccountMapper;
import au.com.royalpay.payment.manage.merchants.beans.NewAccountBean; import au.com.royalpay.payment.manage.merchants.beans.NewAccountBean;
import au.com.royalpay.payment.manage.merchants.core.ClientManager; import au.com.royalpay.payment.manage.merchants.core.ClientManager;
import au.com.royalpay.payment.manage.system.core.MailGunService; import au.com.royalpay.payment.manage.system.core.MailGunService;
import au.com.royalpay.payment.tools.env.PlatformEnvironment; import au.com.royalpay.payment.tools.env.PlatformEnvironment;
import au.com.royalpay.payment.tools.env.SysConfigManager; import au.com.royalpay.payment.tools.env.SysConfigManager;
import au.com.royalpay.payment.tools.exceptions.BadRequestException; import au.com.royalpay.payment.tools.exceptions.BadRequestException;
import au.com.royalpay.payment.tools.exceptions.ForbiddenException;
import au.com.royalpay.payment.tools.exceptions.ServerErrorException; import au.com.royalpay.payment.tools.exceptions.ServerErrorException;
import au.com.royalpay.payment.tools.mail.SendMail; import au.com.royalpay.payment.tools.mail.SendMail;
import au.com.royalpay.payment.tools.utils.sms.SmsSingleSender; import au.com.royalpay.payment.tools.utils.sms.SmsSingleSender;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.RandomStringUtils; import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
@ -21,15 +21,14 @@ import org.springframework.util.Assert;
import org.thymeleaf.context.Context; import org.thymeleaf.context.Context;
import org.thymeleaf.spring4.SpringTemplateEngine; import org.thymeleaf.spring4.SpringTemplateEngine;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
public class SimpleClientApplyServiceImpl implements SimpleClientApplyService { public class SimpleClientApplyServiceImpl implements SimpleClientApplyService {
@Value("${royalpay.sms.appid}") @Value("${royalpay.sms.appid}")
@ -44,6 +43,8 @@ public class SimpleClientApplyServiceImpl implements SimpleClientApplyService {
private SpringTemplateEngine thymeleaf; private SpringTemplateEngine thymeleaf;
@Resource @Resource
private ClientManager clientManager; private ClientManager clientManager;
@Resource
private ClientAccountMapper clientAccountMapper;
@Resource @Resource
private StringRedisTemplate stringRedisTemplate; private StringRedisTemplate stringRedisTemplate;
@ -151,7 +152,7 @@ public class SimpleClientApplyServiceImpl implements SimpleClientApplyService {
if(StringUtils.isNotEmpty(codeKey)){ if(StringUtils.isNotEmpty(codeKey)){
String redisAddress = stringRedisTemplate.boundValueOps(getVerifyMailRedisKey(codeKey)).get(); String redisAddress = stringRedisTemplate.boundValueOps(getVerifyMailRedisKey(codeKey)).get();
if(!address.equals(redisAddress)){ if(!address.equals(redisAddress)){
throw new BadRequestException("Data error"); throw new BadRequestException("Mail expired");
}else { }else {
return codeKey; return codeKey;
} }
@ -167,6 +168,14 @@ public class SimpleClientApplyServiceImpl implements SimpleClientApplyService {
stringRedisTemplate.delete(getVerifyMailRedisKey(codeKey)); stringRedisTemplate.delete(getVerifyMailRedisKey(codeKey));
} }
@Override
public void checkAccountName(String account_name) {
JSONObject account = clientAccountMapper.findByUsernameForDuplicate(account_name);
if (!account.isEmpty()){
throw new ForbiddenException("用户名已被注册");
}
}
private String getRegisterClientRedisKey(String phoneNumber){ private String getRegisterClientRedisKey(String phoneNumber){
return REGISTER_CLIENT_PREFIX +phoneNumber; return REGISTER_CLIENT_PREFIX +phoneNumber;
} }

@ -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.application.core.SimpleClientApplyService;
import au.com.royalpay.payment.manage.merchants.beans.NewAccountBean; 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.CommonConsts;
import au.com.royalpay.payment.tools.http.HttpUtils; import au.com.royalpay.payment.tools.http.HttpUtils;
@ -26,6 +28,15 @@ public class SimpleClientApplyController {
@Resource @Resource
private SimpleClientApplyService simpleClientApplyService; private SimpleClientApplyService simpleClientApplyService;
@Resource @Resource
private SignInAccountService signInAccountService;
@RequestMapping(value = "/account/{account_name}", method = RequestMethod.GET)
@ResponseBody
public void checkAccountName(@PathVariable String account_name, Errors errors){
HttpUtils.handleValidErrors(errors);
simpleClientApplyService.checkAccountName(account_name);
}
@RequestMapping(value = "/account/{codeKey}", method = RequestMethod.POST) @RequestMapping(value = "/account/{codeKey}", method = RequestMethod.POST)
@ResponseBody @ResponseBody
@ -45,6 +56,7 @@ public class SimpleClientApplyController {
simpleClientApplyService.checkOrGenerateVerifyMailKey(address,codeKey); simpleClientApplyService.checkOrGenerateVerifyMailKey(address,codeKey);
ModelAndView view = new ModelAndView("verify_mail"); ModelAndView view = new ModelAndView("verify_mail");
view.addObject("codeKey", codeKey); view.addObject("codeKey", codeKey);
view.addObject("address", address);
return view; return view;
} }
@ -52,10 +64,10 @@ public class SimpleClientApplyController {
@ResponseBody @ResponseBody
public void verifyMail(@PathVariable String codeKey, @PathVariable String address,@RequestBody JSONObject account){ public void verifyMail(@PathVariable String codeKey, @PathVariable String address,@RequestBody JSONObject account){
simpleClientApplyService.checkOrGenerateVerifyMailKey(address,codeKey); simpleClientApplyService.checkOrGenerateVerifyMailKey(address,codeKey);
LoginInfo loginInfo = new LoginInfo();
ModelAndView view = new ModelAndView("verify_mail"); loginInfo.setLoginId(account.getString("userName"));
view.addObject("codeKey", codeKey); loginInfo.setPassword(account.getString("password"));
signInAccountService.accountCheck(loginInfo);
simpleClientApplyService.deleteVerifyMailKey(codeKey); simpleClientApplyService.deleteVerifyMailKey(codeKey);
} }
} }

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

@ -166,6 +166,13 @@ public class SignInAccountServiceImpl implements SignInAccountService, Applicati
return account; 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) { private void validLoginInfo(LoginInfo loginInfo, JSONObject account) {
if (account == null) { if (account == null) {
throw new BadRequestException(LocaleSupport.localeMessage("error.login.password")); throw new BadRequestException(LocaleSupport.localeMessage("error.login.password"));

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

Loading…
Cancel
Save