新增账号注册界面示例
This commit is contained in:
Binary file not shown.
@@ -100,12 +100,10 @@ public class AccountController extends BaseController{
|
||||
UserUtils.putCache("fpUserCode", u.getUserCode());
|
||||
UserUtils.putCache("fpLoginCode", u.getLoginCode());
|
||||
UserUtils.putCache("fpValidCode", fpValidCode);
|
||||
// 发送短信消息。
|
||||
// 发送邮箱或短信验证码
|
||||
if("mobile".equals(validType)){
|
||||
return sendSmsValidCode(u, fpValidCode, text("找回密码"));
|
||||
}
|
||||
// 发送邮件消息。
|
||||
else if("email".equals(validType)){
|
||||
}else if("email".equals(validType)){
|
||||
return sendEmailValidCode(u, fpValidCode, text("找回密码"));
|
||||
}
|
||||
return null;
|
||||
@@ -272,8 +270,8 @@ public class AccountController extends BaseController{
|
||||
@ApiImplicitParam(name = "userName", value = "用户姓名", required = true, paramType="query", type="String"),
|
||||
@ApiImplicitParam(name = "email", value = "电子邮箱", required = true, paramType="query", type="String"),
|
||||
@ApiImplicitParam(name = "mobile", value = "手机号码", required = true, paramType="query", type="String"),
|
||||
@ApiImplicitParam(name = "corpCode", value = "租户编号", required = true, paramType="query", type="String"),
|
||||
@ApiImplicitParam(name = "corpName", value = "租户名称", required = true, paramType="query", type="String"),
|
||||
@ApiImplicitParam(name = "corpCode_", value = "租户编号", required = true, paramType="query", type="String"),
|
||||
@ApiImplicitParam(name = "corpName_", value = "租户名称", required = true, paramType="query", type="String"),
|
||||
@ApiImplicitParam(name = "userType", value = "用户类型(employee)", required = true, paramType="query", type="String"),
|
||||
@ApiImplicitParam(name = "validCode", value = "图片验证码,防止重复机器人", required = true),
|
||||
@ApiImplicitParam(name = "validType", value = "验证方式(mobile、email)", required = true),
|
||||
@@ -287,6 +285,9 @@ public class AccountController extends BaseController{
|
||||
return renderResult(Global.FALSE, text("非法操作。"));
|
||||
}
|
||||
// 非空数据校验。
|
||||
if (Global.isUseCorpModel() && StringUtils.isBlank(user.getCorpCode_())) {
|
||||
return renderResult(Global.FALSE, text("请选择注册到的租户!"));
|
||||
}
|
||||
if (!(StringUtils.isNotBlank(user.getLoginCode()) && StringUtils.isNotBlank(user.getUserName()))){
|
||||
return renderResult(Global.FALSE, text("登录账号和用户姓名不能为空!"));
|
||||
}
|
||||
@@ -305,30 +306,31 @@ public class AccountController extends BaseController{
|
||||
UserUtils.putCache("regLastDate", new Date());
|
||||
}
|
||||
// 验证用户编码是否存在。
|
||||
if (UserUtils.getByLoginCode(user.getLoginCode()) != null){
|
||||
if (UserUtils.getByLoginCode(user.getLoginCode(), user.getCorpCode_()) != null){
|
||||
return renderResult(Global.FALSE, text("登录账号已存在"));
|
||||
}
|
||||
// 生成验证码,并缓存。
|
||||
String code = StringUtils.getRandomNum(6);
|
||||
UserUtils.putCache("regCorpCode", user.getCorpCode());
|
||||
UserUtils.putCache("regCorpName", user.getCorpName());
|
||||
String regValidCode = StringUtils.getRandomNum(6);
|
||||
UserUtils.putCache("regCorpCode", user.getCorpCode_());
|
||||
UserUtils.putCache("regCorpName", user.getCorpName_());
|
||||
UserUtils.putCache("regLoginCode", user.getLoginCode());
|
||||
UserUtils.putCache("regUserName", user.getUserName());
|
||||
// 账号注册类型
|
||||
String[] userTypes = StringUtils.split(Global.getConfig(
|
||||
"sys.account.registerUser.userTypes.userTypes", "-1"), ",");
|
||||
"sys.account.registerUser.userTypes", "-1"), ",");
|
||||
if (StringUtils.inString(user.getUserType(), userTypes)){
|
||||
UserUtils.putCache("regUserType", user.getUserType());
|
||||
}else{
|
||||
return renderResult(Global.FALSE, text("非法的用户类型!"));
|
||||
return renderResult(Global.FALSE, text("请在参数设置里设定允许自助注册的用户类型")+":"+user.getUserType());
|
||||
}
|
||||
UserUtils.putCache("regEmail", user.getEmail());
|
||||
UserUtils.putCache("regMobile", user.getMobile());
|
||||
UserUtils.putCache("regValidCode", code);
|
||||
UserUtils.putCache("regValidCode", regValidCode);
|
||||
// 发送邮箱或短信验证码
|
||||
if("send_email".equals(validType)){
|
||||
return sendEmailValidCode(user, code, text("注册账号"));
|
||||
}else if("send_mobile".equals(validType)){
|
||||
return sendSmsValidCode(user, code, text("注册账号"));
|
||||
if("email".equals(validType)){
|
||||
return sendEmailValidCode(user, regValidCode, text("注册账号"));
|
||||
}else if("mobile".equals(validType)){
|
||||
return sendSmsValidCode(user, regValidCode, text("注册账号"));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -343,7 +345,6 @@ public class AccountController extends BaseController{
|
||||
@ApiOperation(value = "根据短信或邮件验证码注册用户")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "loginCode", value = "登录账号", required = true, paramType="query", type="String"),
|
||||
@ApiImplicitParam(name = "userName", value = "用户姓名", required = true, paramType="query", type="String"),
|
||||
@ApiImplicitParam(name = "password", value = "登录密码", required = true, paramType="query", type="String"),
|
||||
@ApiImplicitParam(name = "regValidCode", value = "手机或邮箱接受的验证码", required = true),
|
||||
})
|
||||
@@ -355,6 +356,7 @@ public class AccountController extends BaseController{
|
||||
String corpName = (String)UserUtils.getCache("regCorpName");
|
||||
String userType = (String)UserUtils.getCache("regUserType");
|
||||
String loginCode = (String)UserUtils.getCache("regLoginCode");
|
||||
String userName = (String)UserUtils.getCache("regUserName");
|
||||
String email = (String)UserUtils.getCache("regEmail");
|
||||
String mobile = (String)UserUtils.getCache("regMobile");
|
||||
String validCode = (String)UserUtils.getCache("regValidCode");
|
||||
@@ -384,21 +386,25 @@ public class AccountController extends BaseController{
|
||||
User u = new User();
|
||||
u.setIsNewRecord(true);
|
||||
if (StringUtils.isNotBlank(corpCode)){
|
||||
u.setCorpCode(corpCode);
|
||||
u.setCorpName(corpName);
|
||||
u.setCorpCode_(corpCode);
|
||||
u.setCorpName_(corpName);
|
||||
}
|
||||
u.setLoginCode(loginCode);
|
||||
u.setUserName(user.getUserName());
|
||||
u.setUserName(userName);
|
||||
u.setPassword(user.getPassword());
|
||||
u.setEmail(email);
|
||||
u.setMobile(mobile);
|
||||
u.setUserType(userType);
|
||||
u.setMgrType(User.MGR_TYPE_NOT_ADMIN);
|
||||
u.setStatus(User.STATUS_AUDIT); // 待审核状态
|
||||
userService.save(u);
|
||||
|
||||
// 验证成功后清理验证码,验证码只允许使用一次。
|
||||
UserUtils.removeCache("regCorpCode");
|
||||
UserUtils.removeCache("regCorpName");
|
||||
UserUtils.removeCache("regUserType");
|
||||
UserUtils.removeCache("regLoginCode");
|
||||
UserUtils.removeCache("regUserName");
|
||||
UserUtils.removeCache("regValidCode");
|
||||
UserUtils.removeCache("regLastDate");
|
||||
|
||||
|
||||
@@ -173,13 +173,6 @@ user:
|
||||
# 登录账号是否租户内唯一,否则全局唯一
|
||||
loginCodeCorpUnique: false
|
||||
|
||||
# 自助账号服务
|
||||
account:
|
||||
# 注册用户
|
||||
registerUser:
|
||||
enabled: false
|
||||
userTypes: 0, 1
|
||||
|
||||
# 角色管理
|
||||
role:
|
||||
# 扩展数据权限定义:3:本部门;4:本公司;5:本部门和本公司
|
||||
@@ -392,6 +385,7 @@ shiro:
|
||||
# ${adminPath}/sys/corpAdmin/treeData = anon
|
||||
# ${adminPath}/** = user
|
||||
filterChainDefinitions: |
|
||||
${adminPath}/sys/corpAdmin/treeData = anon
|
||||
${adminPath}/** = user
|
||||
|
||||
# 默认的授权过滤定义,如果在filterChainDefinitions中已经定义,则该定义会被覆盖。
|
||||
@@ -603,8 +597,8 @@ msg:
|
||||
fromAddress: jeesite_demo@163.com
|
||||
fromPassword: jeesitedemo1234
|
||||
fromHostName: smtp.163.com
|
||||
sslOnConnect: false
|
||||
sslSmtpPort: 994
|
||||
sslOnConnect: true
|
||||
sslSmtpPort: 465
|
||||
|
||||
# 短信网关
|
||||
sms:
|
||||
|
||||
@@ -14,8 +14,8 @@ sys.login.accountIsBlank=登录账号不能为空。
|
||||
sys.login.validCodeError=登录验证码错误,请重试。
|
||||
sys.login.accountDisabled=该帐号已停用。
|
||||
sys.login.accountFreezed=该帐号已冻结。
|
||||
sys.login.accountAudited=该帐号待审核。
|
||||
sys.login.accountInvalid=该帐号无效。
|
||||
sys.login.accountAudited=该帐号等待审核。
|
||||
sys.login.accountInvalid=该帐号无效状态。
|
||||
sys.login.tickOutMessage=账号已被管理员移出在线,请重新登录。
|
||||
sys.login.multiAddrMessage=账号已在其它地方登录,请重新登录。
|
||||
sys.login.failedNumLock=登录失败,尝试次数过多,账号已锁定,请 {0} 分钟后重试.
|
||||
|
||||
@@ -0,0 +1,173 @@
|
||||
<% layout('/layouts/default.html', {title: '账号注册', libs: ['validate'], bodyClass: 'login-page'}){ %>
|
||||
<% include('/include/upgrade.html'){} // 如果客户浏览器版本过低,则显示浏览器升级提示。 %>
|
||||
<link rel="stylesheet" href="${ctxStatic}/icheck/1.0/square/blue.css?${_version}">
|
||||
<link rel="stylesheet" href="${ctxStatic}/jquery-toastr/2.0/toastr.min.css?${_version}">
|
||||
<link rel="stylesheet" href="${ctxStatic}/modules/sys/sysLogin.css?${_version}">
|
||||
<div class="login-box" style="margin-top:3%">
|
||||
<div class="login-logo">
|
||||
<a href="${ctxPath}/account/forgetPwd"><b>${@Global.getConfig('productName')}</b>
|
||||
<small>${@Global.getConfig('productVersion')}</small></a>
|
||||
</div>
|
||||
<div class="login-box-body">
|
||||
<form id="registerForm" action="${ctxPath}/account/saveRegByValidCode" method="post">
|
||||
<div class="form-group has-feedback">
|
||||
<select id="reg_validType" name="op" class="form-control">
|
||||
<option value="email">使用电子邮箱找注册账号</option>
|
||||
<option value="mobile">使用手机号码注册账号</option>
|
||||
</select>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function(){
|
||||
$('#reg_validType').change(function(){
|
||||
var val = $(this).val(), action = '';
|
||||
$('.reg-element').addClass('hide').removeClass('block');
|
||||
$('.reg-'+val).addClass('block').removeClass('hide');
|
||||
setTimeout(function(){
|
||||
$('#reg_loginCode').focus();
|
||||
}, 100);
|
||||
if (val == 'mobile' || val == 'email'){
|
||||
var txt = (val == 'mobile' ? '手机' : '邮箱')
|
||||
$('#regValidCode').attr('placeholder', txt+'验证码')
|
||||
.attr('data-msg-required', '请填写'+txt+'验证码.');
|
||||
$('#sendRegValidCode').val('获取'+txt+'验证码');
|
||||
action = '${ctxPath}/account/saveRegByValidCode';
|
||||
}else if(val == 'question'){
|
||||
action = '${ctxPath}/account/savePwdByPwdQuestion';
|
||||
}
|
||||
$('#registerForm').attr('action', action);
|
||||
}).change();
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
<% if(@Global.isUseCorpModel()){ %>
|
||||
<div class="form-group has-feedback">
|
||||
<#form:treeselect id="reg_corp" title="${text('选择租户')}" allowClear="true"
|
||||
name="corpCode" value="0" labelName="corpName" labelValue="JeeSite"
|
||||
url="${ctx}/sys/corpAdmin/treeData?isShowCode=true"
|
||||
class="required" data-msg-required="请选择所属租户."
|
||||
placeholder="${text('所属租户')}"/>
|
||||
</div>
|
||||
<% } %>
|
||||
<div class="form-group has-feedback">
|
||||
<span class="fa fa-user form-control-feedback"></span>
|
||||
<input type="text" id="reg_loginCode" name="loginCode" class="form-control required" data-msg-required="请填写登录账号." placeholder="登录账号" />
|
||||
</div>
|
||||
<div class="form-group has-feedback">
|
||||
<span class="fa fa-info form-control-feedback"></span>
|
||||
<input type="text" id="reg_userName" name="userName" class="form-control required" data-msg-required="请填写用户姓名." placeholder="用户姓名" />
|
||||
</div>
|
||||
<div class="form-group has-feedback reg-element reg-email">
|
||||
<span class="fa fa-envelope form-control-feedback"></span>
|
||||
<input type="text" id="reg_email" name="email" class="form-control required" data-msg-required="请填写邮箱地址." placeholder="邮箱地址" />
|
||||
</div>
|
||||
<div class="form-group has-feedback reg-element reg-mobile">
|
||||
<span class="fa fa-phone-square form-control-feedback"></span>
|
||||
<input type="text" id="reg_mobile" name="mobile" class="form-control required" data-msg-required="请填写手机号码." placeholder="手机号码" />
|
||||
</div>
|
||||
<input type="hidden" id="reg_userType" name="mobile" value="member" />
|
||||
<div class="form-group has-feedback reg-element reg-mobile reg-email">
|
||||
<#form:validcode id="reg_validCode" name="validCode" isRequired="true" isRemote="true" isLazy="false"/>
|
||||
</div>
|
||||
<div class="form-group has-feedback reg-element reg-mobile reg-email">
|
||||
<div class="input-group">
|
||||
<input type="text" id="regValidCode" name="regValidCode" class="form-control required"
|
||||
data-msg-required="请填写手机验证码." placeholder="手机验证码" />
|
||||
<span class="input-group-btn">
|
||||
<input type="button" id="sendRegValidCode" value="获取手机验证码" class="btn btn-flat"/>
|
||||
</span>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
var waitTime = 60;
|
||||
function sendTime(o) {
|
||||
if (waitTime == 0) {
|
||||
o.removeAttribute("disabled");
|
||||
o.value = "获取验证码";
|
||||
waitTime = 60;
|
||||
} else {
|
||||
o.setAttribute("disabled", true);
|
||||
o.value = "重新发送(" + waitTime + ")";
|
||||
waitTime--;
|
||||
setTimeout(function() {
|
||||
sendTime(o)
|
||||
}, 1000);
|
||||
}
|
||||
}
|
||||
$('#sendRegValidCode').click(function() {
|
||||
var $this = this;
|
||||
js.ajaxSubmit('${ctxPath}/account/getRegValidCode', {
|
||||
validType: $('#reg_validType').val(),
|
||||
corpCode_ : $('#reg_corpCode').val(),
|
||||
corpName_ : $('#reg_corpName').val(),
|
||||
loginCode : $('#reg_loginCode').val(),
|
||||
userName : $('#reg_userName').val(),
|
||||
email : $('#reg_email').val(),
|
||||
mobile : $('#reg_mobile').val(),
|
||||
userType: $('#reg_userType').val(),
|
||||
validCode : $('#reg_validCode').val()
|
||||
}, function(data){
|
||||
js.showMessage(data.message);
|
||||
if (data.result == 'true'){
|
||||
sendTime($this);
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
<div class="form-group has-feedback">
|
||||
<span class="fa fa-lock form-control-feedback"></span>
|
||||
<input type="password" autocomplete="off" id="reg_password" name="password"
|
||||
class="form-control required" data-msg-required="请填写登录密码."
|
||||
rangelength="3,50" data-msg-rangelength="登录密码长度不能小于3并大于50个字符."
|
||||
placeholder="登录密码" />
|
||||
</div>
|
||||
<div class="form-group has-feedback">
|
||||
<span class="fa fa-lock form-control-feedback"></span>
|
||||
<input type="password" autocomplete="off" id="reg_confirmPassword" name="confirmPassword"
|
||||
class="form-control required" data-msg-required="请再填一次登录密码."
|
||||
rangelength="3,50" data-msg-rangelength="登录密码长度不能小于3并大于50个字符."
|
||||
equalTo="#reg_password" data-msg-equalTo="填写的密码与登录密码不同."
|
||||
placeholder="再填一次登录密码" />
|
||||
</div>
|
||||
<div class="form-group has-feedback icheck">
|
||||
<label title="${text('公共场所慎用,下次不需要再填写帐号')}"><input type="checkbox" name="reg_terms"
|
||||
class="form-control required" data-msg-required="请阅读并同意我们的服务条款."> 我已阅读并同意协议内容 </label>
|
||||
<a href="https://gitee.com/thinkgem/jeesite4/blob/master/README.md" target="_blank">查看协议</a>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-xs-6">
|
||||
<button type="submit" class="btn btn-primary btn-block btn-flat"
|
||||
id="btnSubmit">${text('提交')}</button>
|
||||
</div>
|
||||
<div class="col-xs-6">
|
||||
<button type="button" class="btn btn-default btn-block btn-flat"
|
||||
id="btnReset">${text('返回')}</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearfix"></div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="login-copyright">
|
||||
© ${@DateUtils.getYear()} ${@Global.getConfig('productName')} - Powered By <a
|
||||
href="http://jeesite.com">JeeSite ${@Global.getProperty('jeesiteVersion')}</a>
|
||||
</div>
|
||||
</div>
|
||||
<% } %>
|
||||
<script src="${ctxStatic}/jquery-toastr/2.0/toastr.min.js?${_version}"></script>
|
||||
<script>
|
||||
$('#registerForm').validate({
|
||||
ignore: ":hidden",
|
||||
submitHandler: function(form) {
|
||||
js.ajaxSubmitForm($(form), function(data){
|
||||
if (data.result == "true"){
|
||||
alert(data.message);
|
||||
location = "${ctx}/login";
|
||||
}else{
|
||||
js.showMessage(data.message);
|
||||
$('#registerForm').reset();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
$('#btnReset').click(function(){
|
||||
location = '${ctx}/login';
|
||||
});
|
||||
</script>
|
||||
@@ -54,7 +54,7 @@
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
<a href="${ctxPath}/account/forgetPwd" class="pull-left">[ ${text('忘记密码')} ]</a>
|
||||
<% if(@Global.getConfigToBoolean('user.registerUser', 'false')){ %>
|
||||
<% if(@Global.getConfigToBoolean('sys.account.registerUser', 'false')){ %>
|
||||
<a href="${ctxPath}/account/registerUser" class="pull-left ml10">[ ${text('注册账号')} ]</a>
|
||||
<% } %>
|
||||
<% if (@com.jeesite.common.i18n.I18nLocaleResolver.enabled()){ %>
|
||||
|
||||
Reference in New Issue
Block a user