注册功能
This commit is contained in:
@@ -31,12 +31,15 @@ import org.maxkey.authn.support.rememberme.AbstractRemeberMeService;
|
||||
import org.maxkey.authn.support.socialsignon.service.SocialSignOnProviderService;
|
||||
import org.maxkey.authn.support.wsfederation.WsFederationConstants;
|
||||
import org.maxkey.configuration.ApplicationConfig;
|
||||
import org.maxkey.constants.ConstantsOperateMessage;
|
||||
import org.maxkey.constants.ConstantsStatus;
|
||||
import org.maxkey.crypto.password.opt.AbstractOptAuthn;
|
||||
import org.maxkey.domain.UserInfo;
|
||||
import org.maxkey.persistence.service.UserInfoService;
|
||||
import org.maxkey.util.StringUtils;
|
||||
import org.maxkey.web.WebConstants;
|
||||
import org.maxkey.web.WebContext;
|
||||
import org.maxkey.web.message.Message;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -222,4 +225,51 @@ public class LoginEndpoint {
|
||||
|
||||
return "fail";
|
||||
}
|
||||
|
||||
/**
|
||||
* view register
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value={"/register"})
|
||||
public ModelAndView register(HttpServletRequest request,HttpServletResponse response) {
|
||||
|
||||
_logger.debug("LoginController /register.");
|
||||
ModelAndView modelAndView = new ModelAndView("registration/register");
|
||||
Object loginErrorMessage=WebContext.getAttribute(WebConstants.LOGIN_ERROR_SESSION_MESSAGE);
|
||||
modelAndView.addObject("loginErrorMessage", loginErrorMessage==null?"":loginErrorMessage);
|
||||
WebContext.removeAttribute(WebConstants.LOGIN_ERROR_SESSION_MESSAGE);
|
||||
return modelAndView;
|
||||
}
|
||||
|
||||
@RequestMapping(value={"/registeron"})
|
||||
@ResponseBody
|
||||
public Message registeron(UserInfo userInfo,@RequestParam String emailMobile) throws ServletException, IOException {
|
||||
if(StringUtils.isNullOrBlank(emailMobile)) {
|
||||
return new Message(WebContext.getI18nValue("register.emailMobile.error"),"1");
|
||||
}
|
||||
if(StringUtils.isValidEmail(emailMobile)) {
|
||||
userInfo.setEmail(emailMobile);
|
||||
}
|
||||
if(StringUtils.isValidMobileNo(emailMobile)) {
|
||||
userInfo.setMobile(emailMobile);
|
||||
}
|
||||
if(!(StringUtils.isValidEmail(emailMobile)||StringUtils.isValidMobileNo(emailMobile))) {
|
||||
return new Message(WebContext.getI18nValue("register.emailMobile.error"),"1");
|
||||
}
|
||||
UserInfo temp=userInfoService.queryUserInfoByEmailMobile(emailMobile);
|
||||
if(temp!=null) {
|
||||
return new Message(WebContext.getI18nValue("register.emailMobile.exist"),"1");
|
||||
}
|
||||
|
||||
temp=userInfoService.loadByUsername(userInfo.getUsername());
|
||||
if(temp!=null) {
|
||||
return new Message(WebContext.getI18nValue("register.user.error"),"1");
|
||||
}
|
||||
userInfo.setStatus(ConstantsStatus.ACTIVE);
|
||||
if(userInfoService.insert(userInfo)) {
|
||||
return new Message(WebContext.getI18nValue("login.text.register.success"),"0");
|
||||
}
|
||||
return new Message(WebContext.getI18nValue("login.text.register.error"),"1");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,6 +53,11 @@ login.button.login=\u767b\u5f55
|
||||
login.text.currenttime=\u65f6 \u95f4
|
||||
login.text.otherlogins=\u5176\u4ed6\u767b\u5f55\u65b9\u5f0f
|
||||
login.text.register=\u7528\u6237\u6ce8\u518c
|
||||
login.text.register.success=\u6ce8\u518c\u6210\u529f
|
||||
login.text.register.error=\u6ce8\u518c\u5931\u8d25\u000d\u000a
|
||||
register.user.error=\u767B\u9646\u8D26\u53F7\u5DF2\u5B58\u5728
|
||||
register.emailMobile.error=\u90AE\u7BB1\u6216\u624B\u673A\u683C\u5F0F\u9519\u8BEF
|
||||
register.emailMobile.exist=\u90AE\u7BB1\u6216\u624B\u673A\u5DF2\u5B58\u5728
|
||||
|
||||
login.password.expired=\u5bc6\u7801\u8fc7\u671f
|
||||
login.password.expired.tip=\u5bc6\u7801\u8fc7\u671f\uff0c\u8bf7\u4fee\u6539\u5bc6\u7801
|
||||
|
||||
@@ -53,6 +53,11 @@ login.button.login=Login
|
||||
login.text.currenttime=CurrentTime
|
||||
login.text.otherlogins=OtherLogins
|
||||
login.text.register=Register
|
||||
login.text.register.success=Register successful
|
||||
login.text.register.error=Register error
|
||||
register.user.error=username exist
|
||||
register.emailMobile.error=email or mobile error
|
||||
register.emailMobile.exist=email or mobile exist
|
||||
|
||||
login.password.expired=Password Expired
|
||||
login.password.expired.tip=Password expired, please change password
|
||||
|
||||
@@ -53,6 +53,11 @@ login.button.login=\u767b\u5f55
|
||||
login.text.currenttime=\u65f6 \u95f4
|
||||
login.text.otherlogins=\u5176\u4ed6\u767b\u5f55\u65b9\u5f0f
|
||||
login.text.register=\u7528\u6237\u6ce8\u518c
|
||||
login.text.register.success=\u6ce8\u518c\u6210\u529f
|
||||
login.text.register.error=\u6ce8\u518c\u5931\u8d25\u000d\u000a
|
||||
register.user.error=\u767B\u9646\u8D26\u53F7\u5DF2\u5B58\u5728
|
||||
register.emailMobile.error=\u90AE\u7BB1\u6216\u624B\u673A\u683C\u5F0F\u9519\u8BEF
|
||||
register.emailMobile.exist=\u90AE\u7BB1\u6216\u624B\u673A\u5DF2\u5B58\u5728
|
||||
|
||||
login.password.expired=\u5bc6\u7801\u8fc7\u671f
|
||||
login.password.expired.tip=\u5bc6\u7801\u8fc7\u671f\uff0c\u8bf7\u4fee\u6539\u5bc6\u7801
|
||||
|
||||
@@ -168,6 +168,9 @@ $(function(){
|
||||
<#--todo:send captcha-->
|
||||
captchaCountTimer=setInterval("getCaptchaCount()", 1000);
|
||||
});
|
||||
$('#register').on('click',function(){
|
||||
window.location.href="<@base />/register";
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -1,63 +1,125 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<base href="<@base/>">
|
||||
|
||||
<title>My JSP 'register.jsp' starting page</title>
|
||||
|
||||
<meta http-equiv="pragma" content="no-cache">
|
||||
<meta http-equiv="cache-control" content="no-cache">
|
||||
<meta http-equiv="expires" content="0">
|
||||
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
|
||||
<meta http-equiv="description" content="This is my page">
|
||||
<!DOCTYPE HTML>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
|
||||
<#include "../layout/header.ftl">
|
||||
<#include "../layout/common.cssjs.ftl">
|
||||
<script type="text/javascript">
|
||||
$(function(){
|
||||
|
||||
</head>
|
||||
|
||||
<body>
|
||||
$('#j_captchaimg').click(function () {//
|
||||
$(this).attr("src", "<@base />/captcha");
|
||||
});
|
||||
|
||||
$('#btn_save').on('click',function(){
|
||||
if($('#emailMobile').val()==''){
|
||||
alert('<@locale code="forgotpassword.emailmobile"/>'+': empty');
|
||||
return false;
|
||||
}
|
||||
if($('#username').val()==''){
|
||||
alert('<@locale code="userinfo.username"/>'+': empty');
|
||||
return false;
|
||||
}
|
||||
if($('#displayName').val()==''){
|
||||
alert('<@locale code="userinfo.displayName"/>'+': empty');
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if($('#password').val()==''){
|
||||
alert('<@locale code="login.text.password"/>'+': empty');
|
||||
return false;
|
||||
}
|
||||
if($('#confirmpassword').val()==''){
|
||||
alert('<@locale code="login.password.confirmPassword"/>'+': empty');
|
||||
return false;
|
||||
}
|
||||
if($('#password').val()!=$('#confirmpassword').val()){
|
||||
alert('<@locale code="login.password.confirmPassword"/>'+'、'+'<@locale code="login.text.password"/>'+': error');
|
||||
return false;
|
||||
}
|
||||
formSubmit();
|
||||
|
||||
})
|
||||
|
||||
function formSubmit(){
|
||||
var uname=$('#username').val();
|
||||
var pwd=$('#password').val();
|
||||
var eMobile=$('#emailMobile').val();
|
||||
var dName=$('#displayName').val();
|
||||
$.ajax({
|
||||
type:"POST",
|
||||
url:"<@base/>/registeron",
|
||||
data:{
|
||||
username:uname,
|
||||
password:pwd,
|
||||
emailMobile:eMobile,
|
||||
displayName:dName
|
||||
},
|
||||
success:function(data){
|
||||
if(data.code=='0'){
|
||||
alert(data.message);
|
||||
window.location.href="<@base/>/login";
|
||||
}else{
|
||||
alert(data.message);
|
||||
}
|
||||
},
|
||||
error:function(jqXHR){
|
||||
alert("error:"+ jqXHR.status);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
<body >
|
||||
<div id="top">
|
||||
<#include "../layout/nologintop.ftl">
|
||||
</div>
|
||||
<div class="container">
|
||||
<table border="0" style="width:100%;">
|
||||
<tr>
|
||||
<td width="630px">
|
||||
|
||||
</td>
|
||||
<td>
|
||||
<form action="<@base />/registration/register" method="post">
|
||||
<table class="datatable">
|
||||
<div class="row">
|
||||
<div class="col-md-2"></div>
|
||||
<div class="col-md-8">
|
||||
<form action="<@base/>/register.do" method="post" class="needs-validation" novalidate>
|
||||
<table class="table table-bordered">
|
||||
<tr>
|
||||
<td><@locale code="register.lastname"/></td>
|
||||
<td><input type='text' id="lastName" name="lastName" value="" /></td>
|
||||
<td><@locale code="forgotpassword.emailmobile"/></td>
|
||||
<td><input required="" type="text" id="emailMobile" name="emailMobile" class="form-control" title="" value=""/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><@locale code="register.firstname"/></td>
|
||||
<td><input type='text' id="firstName" name="firstName" value="" /></td>
|
||||
<td><@locale code="login.text.captcha"/>:</td>
|
||||
<td><input required="" class="form-control" type='text' id="j_captcha" name="captcha" tabindex="3" value="" style="float: left;"/><img id="j_captchaimg" src="<@base/>/captcha"/></td>
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td><@locale code="register.workemail"/></td>
|
||||
<td><input type='text' id="workEmail" name="workEmail" value="" /></td>
|
||||
<td><@locale code="userinfo.displayName"/>:</td>
|
||||
<td><input required="" class="form-control" type='text' id='displayName' name='displayName' tabindex="1"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><@locale code="register.company"/></td>
|
||||
<td><input type='text' id="company" name="company" value="" /></td>
|
||||
<td><@locale code="userinfo.username"/>:</td>
|
||||
<td><input required="" class="form-control" type='text' id='username' name='username' tabindex="1"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><@locale code="register.workphone"/></td>
|
||||
<td><input type='text' id="workPhone" name="workPhone" value="" /></td>
|
||||
</tr>
|
||||
|
||||
<tr style="display:none">
|
||||
<td><@locale code="register.users"/></td>
|
||||
<td><input type='text' id="users" name="users" value="0" /></td>
|
||||
<td><@locale code="login.text.password"/></td>
|
||||
<td><input required="" class="form-control" type='password' id="password" name="password" tabindex="1" value="" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2"><input id="registerBtn" class="button" type="submit" value="<@locale code="register.button.register" />"/></td>
|
||||
<td><@locale code="login.password.confirmPassword"/></td>
|
||||
<td><input required="" class="form-control" type='password' id="confirmpassword" name="confirmpassword" tabindex="2" value="" /></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td colspan="2"><input id="btn_save" class="button btn btn-lg btn-primary btn-block" type="button" value="<@locale code="login.text.register" />"/></td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
<div class="col-md-2"></div>
|
||||
</div >
|
||||
</div>
|
||||
<div id="footer">
|
||||
<#include "../layout/footer.ftl">
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user