Commit ccbb7df4 authored by dashu's avatar dashu

添加用户注册,管理员审核

parent 39004c72
...@@ -55,7 +55,8 @@ import org.json.JSONObject; ...@@ -55,7 +55,8 @@ import org.json.JSONObject;
* Index processor. * Index processor.
* *
* @author <a href="mailto:DL88250@gmail.com">Liang Ding</a> * @author <a href="mailto:DL88250@gmail.com">Liang Ding</a>
* @version 1.1.1.0, Oct 11, 2012 * @author <a href="mailto:385321165@qq.com">DASHU</a>
* @version 1.1.1.1, Mar 30, 2013
* @since 0.3.1 * @since 0.3.1
*/ */
@RequestProcessor @RequestProcessor
...@@ -188,6 +189,45 @@ public final class IndexProcessor { ...@@ -188,6 +189,45 @@ public final class IndexProcessor {
} }
} }
/**
* Show register page.
*
* @param context the specified context
* @param request the specified HTTP servlet request
* @param response the specified HTTP servlet response
*/
@RequestProcessing(value = "/register.html", method = HTTPRequestMethod.GET)
public void register(final HTTPRequestContext context, final HttpServletRequest request, final HttpServletResponse response) {
final AbstractFreeMarkerRenderer renderer = new ConsoleRenderer();
context.setRenderer(renderer);
renderer.setTemplateName("register.ftl");
final Map<String, Object> dataModel = renderer.getDataModel();
try {
final Map<String, String> langs = langPropsService.getAll(Locales.getLocale(request));
dataModel.putAll(langs);
final JSONObject preference = preferenceQueryService.getPreference();
filler.fillBlogFooter(dataModel, preference);
filler.fillMinified(dataModel);
Keys.fillServer(dataModel);
} catch (final ServiceException e) {
LOGGER.log(Level.SEVERE, e.getMessage(), e);
try {
response.sendError(HttpServletResponse.SC_NOT_FOUND);
} catch (final IOException ex) {
LOGGER.severe(ex.getMessage());
}
}
}
/** /**
* Gets the request page number from the specified request URI. * Gets the request page number from the specified request URI.
* *
......
...@@ -22,6 +22,8 @@ import javax.servlet.http.HttpServletRequest; ...@@ -22,6 +22,8 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import org.b3log.latke.Keys; import org.b3log.latke.Keys;
import org.b3log.latke.Latkes; import org.b3log.latke.Latkes;
import org.b3log.latke.model.Role;
import org.b3log.latke.model.User;
import org.b3log.latke.service.LangPropsService; import org.b3log.latke.service.LangPropsService;
import org.b3log.latke.service.ServiceException; import org.b3log.latke.service.ServiceException;
import org.b3log.latke.servlet.HTTPRequestContext; import org.b3log.latke.servlet.HTTPRequestContext;
...@@ -41,7 +43,8 @@ import org.json.JSONObject; ...@@ -41,7 +43,8 @@ import org.json.JSONObject;
* User console request processing. * User console request processing.
* *
* @author <a href="mailto:DL88250@gmail.com">Liang Ding</a> * @author <a href="mailto:DL88250@gmail.com">Liang Ding</a>
* @version 1.0.0.2, Jan 29, 2013 * @author <a href="mailto:385321165@qq.com">DASHU</a>
* @version 1.0.0.3, Mar 30, 2013
* @since 0.4.0 * @since 0.4.0
*/ */
@RequestProcessor @RequestProcessor
...@@ -163,10 +166,6 @@ public final class UserConsole { ...@@ -163,10 +166,6 @@ public final class UserConsole {
@RequestProcessing(value = "/console/user/", method = HTTPRequestMethod.POST) @RequestProcessing(value = "/console/user/", method = HTTPRequestMethod.POST)
public void addUser(final HttpServletRequest request, final HttpServletResponse response, final HTTPRequestContext context) public void addUser(final HttpServletRequest request, final HttpServletResponse response, final HTTPRequestContext context)
throws Exception { throws Exception {
if (!userUtils.isAdminLoggedIn(request)) {
response.sendError(HttpServletResponse.SC_FORBIDDEN);
return;
}
final JSONRenderer renderer = new JSONRenderer(); final JSONRenderer renderer = new JSONRenderer();
...@@ -177,6 +176,12 @@ public final class UserConsole { ...@@ -177,6 +176,12 @@ public final class UserConsole {
try { try {
final JSONObject requestJSONObject = Requests.parseRequestJSONObject(request, response); final JSONObject requestJSONObject = Requests.parseRequestJSONObject(request, response);
if (userUtils.isAdminLoggedIn(request)) {
requestJSONObject.put(User.USER_ROLE, Role.DEFAULT_ROLE);
} else {
requestJSONObject.put(User.USER_ROLE, Role.VISITOR_ROLE);
}
final String userId = userMgmtService.addUser(requestJSONObject); final String userId = userMgmtService.addUser(requestJSONObject);
ret.put(Keys.OBJECT_ID, userId); ret.put(Keys.OBJECT_ID, userId);
...@@ -368,4 +373,54 @@ public final class UserConsole { ...@@ -368,4 +373,54 @@ public final class UserConsole {
jsonObject.put(Keys.MSG, langPropsService.get("getFailLabel")); jsonObject.put(Keys.MSG, langPropsService.get("getFailLabel"));
} }
} }
/**
* Change a user role.
*
* <p>
* Renders the response with a json object, for example,
* <pre>
* {
* "sc": boolean,
* "msg": ""
* }
* </pre>
* </p>
*
* @param request the specified http servlet request
* @param response the specified http servlet response
* @param context the specified http request context
* @throws Exception exception
*/
@RequestProcessing(value = "/console/changeRole/*", method = HTTPRequestMethod.GET)
public void changeUserRole(final HttpServletRequest request, final HttpServletResponse response, final HTTPRequestContext context)
throws Exception {
if (!userUtils.isAdminLoggedIn(request)) {
response.sendError(HttpServletResponse.SC_FORBIDDEN);
return;
}
final JSONRenderer renderer = new JSONRenderer();
context.setRenderer(renderer);
final JSONObject jsonObject = new JSONObject();
renderer.setJSONObject(jsonObject);
try {
final String userId = request.getRequestURI().substring((Latkes.getContextPath() + "/console/changeRole/").length());
userMgmtService.changeRole(userId);
jsonObject.put(Keys.STATUS_CODE, true);
jsonObject.put(Keys.MSG, langPropsService.get("updateSuccLabel"));
} catch (final ServiceException e) {
LOGGER.log(Level.SEVERE, e.getMessage(), e);
jsonObject.put(Keys.STATUS_CODE, false);
jsonObject.put(Keys.MSG, langPropsService.get("removeFailLabel"));
}
}
} }
...@@ -36,7 +36,8 @@ import org.json.JSONObject; ...@@ -36,7 +36,8 @@ import org.json.JSONObject;
* User management service. * User management service.
* *
* @author <a href="mailto:DL88250@gmail.com">Liang Ding</a> * @author <a href="mailto:DL88250@gmail.com">Liang Ding</a>
* @version 1.0.0.3, Jan 4, 2013 * @author <a href="mailto:385321165@qq.com">DASHU</a>
* @version 1.0.0.4, Mar 30, 2013
* @since 0.4.0 * @since 0.4.0
*/ */
public final class UserMgmtService { public final class UserMgmtService {
...@@ -112,6 +113,42 @@ public final class UserMgmtService { ...@@ -112,6 +113,42 @@ public final class UserMgmtService {
} }
} }
/**
* change user role by the specified userid.
*
* @param userId the specified userid
* @throws ServiceException exception
*/
public void changeRole(final String userId) throws ServiceException {
final Transaction transaction = userRepository.beginTransaction();
try {
final JSONObject oldUser = userRepository.get(userId);
if (null == oldUser) {
throw new ServiceException(langPropsService.get("updateFailLabel"));
}
final String role = oldUser.optString(User.USER_ROLE);
if (Role.VISITOR_ROLE.equals(role)) {
oldUser.put(User.USER_ROLE, Role.DEFAULT_ROLE);
} else if (Role.DEFAULT_ROLE.equals(role)) {
oldUser.put(User.USER_ROLE, Role.VISITOR_ROLE);
}
userRepository.update(userId, oldUser);
transaction.commit();
} catch (final RepositoryException e) {
if (transaction.isActive()) {
transaction.rollback();
}
LOGGER.log(Level.SEVERE, "Updates a user failed", e);
throw new ServiceException(e);
}
}
/** /**
* Adds a user with the specified request json object. * Adds a user with the specified request json object.
* *
......
...@@ -21,6 +21,7 @@ import java.util.logging.Logger; ...@@ -21,6 +21,7 @@ import java.util.logging.Logger;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import org.b3log.latke.Keys; import org.b3log.latke.Keys;
import org.b3log.latke.model.Role;
import org.b3log.latke.model.User; import org.b3log.latke.model.User;
import org.b3log.latke.repository.Query; import org.b3log.latke.repository.Query;
import org.b3log.latke.repository.RepositoryException; import org.b3log.latke.repository.RepositoryException;
...@@ -44,7 +45,8 @@ import org.json.JSONObject; ...@@ -44,7 +45,8 @@ import org.json.JSONObject;
* User utilities. * User utilities.
* *
* @author <a href="mailto:DL88250@gmail.com">Liang Ding</a> * @author <a href="mailto:DL88250@gmail.com">Liang Ding</a>
* @version 1.0.1.3, Feb 7, 2012 * @author <a href="mailto:385321165@qq.com">DASHU</a>
* @version 1.0.1.4, Mar 30, 2013
* @since 0.3.1 * @since 0.3.1
*/ */
public final class Users { public final class Users {
...@@ -214,6 +216,10 @@ public final class Users { ...@@ -214,6 +216,10 @@ public final class Users {
for (int i = 0; i < users.length(); i++) { for (int i = 0; i < users.length(); i++) {
final JSONObject user = users.getJSONObject(i); final JSONObject user = users.getJSONObject(i);
if (isVisitor(user)) {
return false;
}
if (user.getString(User.USER_EMAIL).equalsIgnoreCase(email)) { if (user.getString(User.USER_EMAIL).equalsIgnoreCase(email)) {
return true; return true;
} }
...@@ -222,6 +228,20 @@ public final class Users { ...@@ -222,6 +228,20 @@ public final class Users {
return false; return false;
} }
/**
* Check the user is visitor or not.
*
* @param user the specified user
* @return {@code true} if is visitor, {@code false} otherwise
* @throws JSONException json exception
*/
private boolean isVisitor(final JSONObject user) throws JSONException {
if (user.getString(User.USER_ROLE).equals(Role.VISITOR_ROLE)) {
return true;
}
return false;
}
/** /**
* Gets the {@link Users} singleton. * Gets the {@link Users} singleton.
* *
......
...@@ -56,7 +56,7 @@ aboutContentLabel=<p><a href="https://github.com/b3log/b3log-solo" target="_blan ...@@ -56,7 +56,7 @@ aboutContentLabel=<p><a href="https://github.com/b3log/b3log-solo" target="_blan
is an open source (<a href="http://www.apache.org/licenses/LICENSE-2.0.html" target="_blank">Apache License 2.0</a>) blogging program, which can run on <a href="http://code.google.com/appengine" target="_blank">Google App Engine</a> and a standard Servlet container.</p>\ is an open source (<a href="http://www.apache.org/licenses/LICENSE-2.0.html" target="_blank">Apache License 2.0</a>) blogging program, which can run on <a href="http://code.google.com/appengine" target="_blank">Google App Engine</a> and a standard Servlet container.</p>\
<p><a href="http://b3log.org" target="_blank">B3log</a> advocates the rights of equality, freedom and passion, and we are trying to create a bran-new experience about individual blogging + community. Sound interesting? <a href="https://github.com/b3log/b3log-solo/wiki/Join_us" target="_blank">Join us</a>!</p>\ <p><a href="http://b3log.org" target="_blank">B3log</a> advocates the rights of equality, freedom and passion, and we are trying to create a bran-new experience about individual blogging + community. Sound interesting? <a href="https://github.com/b3log/b3log-solo/wiki/Join_us" target="_blank">Join us</a>!</p>\
<a target="blank" href="http://me.alipay.com/b3log">\ <a target="blank" href="http://me.alipay.com/b3log">\
<div class="ico-alipay-me" alt="Alipay B3log" title="\u901a\u8fc7\u652f\u4ed8\u5b9d\u6536\u6b3e\u4e3b\u9875\u8fdb\u884c\u6350\u8d60"></div></a> <div class="ico-alipay-me" alt="Alipay B3log" title="\u901A\u8FC7\u652F\u4ED8\u5B9D\u6536\u6B3E\u4E3B\u9875\u8FDB\u884C\u6350\u8D60"></div></a>
confirmLabel=Confirm confirmLabel=Confirm
adminConsoleLabel=Admin adminConsoleLabel=Admin
adminIndexLabel=Admin Index adminIndexLabel=Admin Index
...@@ -66,6 +66,7 @@ commentListLabel=Comments ...@@ -66,6 +66,7 @@ commentListLabel=Comments
draftListLabel=Drafts draftListLabel=Drafts
userManageLabel=Users userManageLabel=Users
commonUserLabel=Common User commonUserLabel=Common User
visitorUserLabel=visitor
addUserLabel=Add User addUserLabel=Add User
updateUserLabel=Update User updateUserLabel=Update User
linkManagementLabel=Links linkManagementLabel=Links
...@@ -263,9 +264,9 @@ Welcome to the <a href="http://symphony.b3log.org" target="_blank">B3log Symphon ...@@ -263,9 +264,9 @@ Welcome to the <a href="http://symphony.b3log.org" target="_blank">B3log Symphon
<span style="font-size:12px"><span style="color:red">Note</span>: Only to ensure Email is the same and <a href="/article/1353772377257" target="_blank">synchronization configured</a> is correctly,\ <span style="font-size:12px"><span style="color:red">Note</span>: Only to ensure Email is the same and <a href="/article/1353772377257" target="_blank">synchronization configured</a> is correctly,\
Your posts and comments can <i>maintain bisynchronous</i> in the community and the B3log Solo.</p> Your posts and comments can <i>maintain bisynchronous</i> in the community and the B3log Solo.</p>
killBrowserLabel=<h2>Let's kill outdated and insecure browser!</h2><p>Let's kill outdated and insecure browser for browser evolution, human progress and better experience.</p><p>You can download</p><ul><li><a href="http://www.mozilla.com/" target="_blank">Firefox</a></li><li><a href="http://www.google.com/chrome" target="_blank">Chrome</a></li><li><a href="http://windows.microsoft.com/en-US/internet-explorer/downloads/ie" target="_blank">IE8 / IE9</a></li><li><a href="http://www.maxthon.com/" target="_blank">Maxthon</a> and <a href="http://www.google.com" target="_blank">so on</a>.</li></ul><span style="font-size: 10px">Tip: Remove "Util.killIE();" in /js/common.js can support all browser.</span> killBrowserLabel=<h2>Let's kill outdated and insecure browser!</h2><p>Let's kill outdated and insecure browser for browser evolution, human progress and better experience.</p><p>You can download</p><ul><li><a href="http://www.mozilla.com/" target="_blank">Firefox</a></li><li><a href="http://www.google.com/chrome" target="_blank">Chrome</a></li><li><a href="http://windows.microsoft.com/en-US/internet-explorer/downloads/ie" target="_blank">IE8 / IE9</a></li><li><a href="http://www.maxthon.com/" target="_blank">Maxthon</a> and <a href="http://www.google.com" target="_blank">so on</a>.</li></ul><span style="font-size: 10px">Tip: Remove "Util.killIE();" in /js/common.js can support all browser.</span>
readmoreLabel=Read more\u00bb readmoreLabel=Read more\u00BB
readmore2Label=Read more readmore2Label=Read more
replyLabel=Reply\u00bb replyLabel=Reply\u00BB
homeLabel=Home homeLabel=Home
enableArticleUpdateHint1Label=Enable Article Update Hint: enableArticleUpdateHint1Label=Enable Article Update Hint:
allowVisitDraftViaPermalink1Label=Allow Visit Draft Via Link: allowVisitDraftViaPermalink1Label=Allow Visit Draft Via Link:
...@@ -346,8 +347,8 @@ duplicatedPermalinkLabel=Duplicated permalink! ...@@ -346,8 +347,8 @@ duplicatedPermalinkLabel=Duplicated permalink!
invalidPermalinkFormatLabel=Invalid permalink format! invalidPermalinkFormatLabel=Invalid permalink format!
duplicatedEmailLabel=Duplicated email! duplicatedEmailLabel=Duplicated email!
refreshAndRetryLabel=Please refresh and try again! refreshAndRetryLabel=Please refresh and try again!
editorLeaveLabel=Content is not null, Do you leave\uff1f editorLeaveLabel=Content is not null, Do you leave\uFF1F
editorPostLabel=Content is not null, Do you clear\uff1f editorPostLabel=Content is not null, Do you clear\uFF1F
#### ####
confirmRemoveLabel=Are You Remove confirmRemoveLabel=Are You Remove
confirmInitLabel=Are You Sure? confirmInitLabel=Are You Sure?
...@@ -369,4 +370,6 @@ helloWorld.content=<p>Welcome to \ ...@@ -369,4 +370,6 @@ helloWorld.content=<p>Welcome to \
<span style="color: blue;">G</span> \ <span style="color: blue;">G</span> \
<span style="color: orangered; font-weight: bold;">Solo</span></a>\ <span style="color: orangered; font-weight: bold;">Solo</span></a>\
. This is your first post. Edit or delete it, then start blogging!</p> . This is your first post. Edit or delete it, then start blogging!</p>
helloWorld.comment.content=Hi, this is a comment. _esc_enter_88250_To delete a comment, just log in and view the post's comments. There you will have the option to delete them. helloWorld.comment.content=Hi, this is a comment. _esc_enter_88250_To delete a comment, just log in and view the post's comments. There you will have the option to delete them.
\ No newline at end of file registerSoloUser=Register Solo User
changeUserRole=Change Role
\ No newline at end of file
...@@ -105,11 +105,18 @@ admin.userList = { ...@@ -105,11 +105,18 @@ admin.userList = {
userData[i].isAdmin = "&nbsp;" + Label.administratorLabel; userData[i].isAdmin = "&nbsp;" + Label.administratorLabel;
userData[i].expendRow = "<a href='javascript:void(0)' onclick=\"admin.userList.get('" + userData[i].expendRow = "<a href='javascript:void(0)' onclick=\"admin.userList.get('" +
users[i].oId + "', '" + users[i].userRole + "')\">" + Label.updateLabel + "</a>"; users[i].oId + "', '" + users[i].userRole + "')\">" + Label.updateLabel + "</a>";
} else { } else if ("defaultRole" === users[i].userRole) {
userData[i].expendRow = "<a href='javascript:void(0)' onclick=\"admin.userList.get('" + userData[i].expendRow = "<a href='javascript:void(0)' onclick=\"admin.userList.get('" +
users[i].oId + "', '" + users[i].userRole + "')\">" + Label.updateLabel + "</a>\ users[i].oId + "', '" + users[i].userRole + "')\">" + Label.updateLabel + "</a>\
<a href='javascript:void(0)' onclick=\"admin.userList.del('" + users[i].oId + "', '" + users[i].userName + "')\">" + Label.removeLabel + "</a>"; <a href='javascript:void(0)' onclick=\"admin.userList.del('" + users[i].oId + "', '" + users[i].userName + "')\">" + Label.removeLabel + "</a>" +
"<a href='javascript:void(0)' onclick=\"admin.userList.changeRole('" + users[i].oId + "')\">" + "ChangeRole" + "</a>";
userData[i].isAdmin = Label.commonUserLabel; userData[i].isAdmin = Label.commonUserLabel;
} else {
userData[i].expendRow = "<a href='javascript:void(0)' onclick=\"admin.userList.get('" +
users[i].oId + "', '" + users[i].userRole + "')\">" + Label.updateLabel + "</a>\
<a href='javascript:void(0)' onclick=\"admin.userList.del('" + users[i].oId + "', '" + users[i].userName + "')\">" + Label.removeLabel + "</a>" +
"<a href='javascript:void(0)' onclick=\"admin.userList.changeRole('" + users[i].oId + "')\">" + "ChangeRole" + "</a>";
userData[i].isAdmin = Label.visitorUserLabel;
} }
} }
...@@ -281,6 +288,39 @@ admin.userList = { ...@@ -281,6 +288,39 @@ admin.userList = {
}); });
} }
}, },
/**
* 修改角色
* @param id
*/
changeRole : function(id){
$.ajax({
url: latkeConfig.servePath + "/console/changeRole/" + id,
type: "GET",
cache: false,
success: function(result, textStatus){
$("#tipMsg").text(result.msg);
if (!result.sc) {
$("#loadMsg").text("");
return;
}
var pageNum = admin.userList.pageInfo.currentPage;
if (admin.userList.pageInfo.currentCount === 1 && admin.userList.pageInfo.pageCount !== 1 &&
admin.userList.pageInfo.currentPage === admin.userList.pageInfo.pageCount) {
admin.userList.pageInfo.pageCount--;
pageNum = admin.userList.pageInfo.pageCount;
}
var hashList = window.location.hash.split("/");
if (pageNum !== parseInt(hashList[hashList.length - 1])) {
admin.setHashByPage(pageNum);
}
admin.userList.getList(pageNum);
$("#loadMsg").text("");
}
});
},
/* /*
* 验证字段 * 验证字段
......
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>${blogTitle}</title>
<meta name="keywords" content="GAE 博客,blog,b3log,kill IE6" />
<meta name="description" content="An open source blog based on GAE Java,GAE Java 开源博客,Let's kill IE6" />
<meta name="author" content="B3log Team" />
<meta name="generator" content="B3log" />
<meta name="copyright" content="B3log" />
<meta name="revised" content="B3log, ${year}" />
<meta http-equiv="Window-target" content="_top" />
<link type="text/css" rel="stylesheet" href="${staticServePath}/css/default-init${miniPostfix}.css?${staticResourceVersion}" charset="utf-8" />
<link rel="icon" type="image/png" href="${staticServePath}/favicon.png" />
</head>
<body>
<div class="wrapper">
<div class="wrap">
<div class="content">
<div class="logo">
<a href="http://b3log.org" target="_blank">
<img border="0" width="153" height="56" alt="B3log" title="B3log" src="${staticServePath}/images/logo.jpg"/>
</a>
</div>
<div class="main">
<div id="user">
<table>
<tr>
<td colspan="2">
${registerSoloUser}
</td>
</tr>
<tr>
<td width="170px">
<label for="userEmail">
${commentEmail1Label}
</label>
</td>
<td>
<input id="userEmail" />
</td>
</tr>
<tr>
<td>
<label for="userName">
${userName1Label}
</label>
</td>
<td>
<input id="userName" />
</td>
</tr>
<tr>
<td>
<label for="userPassword">
${userPassword1Label}
</label>
</td>
<td>
<input type="password" id="userPassword" />
</td>
</tr>
<tr>
<td>
<label for="userPasswordConfirm">
${userPasswordConfirm1Label}
</label>
</td>
<td>
<input type="password" id="userPasswordConfirm" />
</td>
</tr>
<tr>
<td colspan="2">
<button onclick='getUserInfo();'>${saveLabel}</button>
</td>
</tr>
<tr>
<td colspan="2">
<span id="tip" ></span>
</td>
</tr>
</table>
</div>
</div>
<span class="clear"></span>
</div>
</div>
<div class="footerWrapper">
<div class="footer">
&copy; ${year} - <a href="${servePath}">${blogTitle}</a><br/>
Powered by
<a href="http://b3log.org" target="_blank">
${b3logLabel}&nbsp;
<span class="solo">Solo</span></a>,
ver ${version}
</div>
</div>
</div>
<script type="text/javascript" src="${staticServePath}/js/lib/jquery/jquery.min.js" charset="utf-8"></script>
<script type="text/javascript">
var validate = function () {
var userName = $("#userName").val().replace(/(^\s*)|(\s*$)/g, "");
if (!/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i.test($("#userEmail").val())) {
$("#tip").text("${mailInvalidLabel}");
$("#userEmail").focus();
} else if (2 > userName.length || userName.length > 20) {
$("#tip").text("${nameTooLongLabel}");
$("#userName").focus();
} else if ($("#userPassword").val().replace(/\s/g, "") === "") {
$("#tip").text("${passwordEmptyLabel}");
$("#userPassword").focus();
} else if ($("#userPassword").val() !== $("#userPasswordConfirm").val()) {
$("#tip").text("${passwordNotMatchLabel}");
$("#userPasswordConfirm").focus();
} else {
$("#tip").text("");
return true;
}
return false;
};
var getUserInfo = function () {
if (validate()) {
var requestJSONObject = {
"userName": $("#userName").val(),
"userEmail": $("#userEmail").val(),
"userPassword": $("#userPassword").val()
};
$.ajax({
url: "${contextPath}" + "/console/user/",
type: "POST",
cache: false,
data: JSON.stringify(requestJSONObject),
success: function(result, textStatus){
$("#tip").text(result.msg);
if (!result.sc) {
return;
}
setTimeout(function(){
window.location.href = "${servePath}";
}, 1000);
}
})
}
}
$(function(){
$("#userPasswordConfirm").keypress(function (event) {
if (event.keyCode === 13) {
getUserInfo();
}
});
});
</script>
</body>
</html>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment