Commit f271af1b authored by Liang Ding's avatar Liang Ding

注册用户加入 URL 字段

暂时没有加入升级程序,所以需要重新初始化开发库。
parent dcc31bcc
...@@ -60,6 +60,7 @@ import org.json.JSONObject; ...@@ -60,6 +60,7 @@ import org.json.JSONObject;
@RequestProcessor @RequestProcessor
// TODO: 060 // TODO: 060
// 1. Add column Preference.feedOutputCnt // 1. Add column Preference.feedOutputCnt
// 2. Add column User.userURL
public final class UpgradeProcessor { public final class UpgradeProcessor {
/** /**
......
...@@ -44,7 +44,7 @@ import org.json.JSONObject; ...@@ -44,7 +44,7 @@ import org.json.JSONObject;
* *
* @author <a href="mailto:DL88250@gmail.com">Liang Ding</a> * @author <a href="mailto:DL88250@gmail.com">Liang Ding</a>
* @author <a href="mailto:385321165@qq.com">DASHU</a> * @author <a href="mailto:385321165@qq.com">DASHU</a>
* @version 1.0.0.3, Mar 30, 2013 * @version 1.0.0.4, Apr 2, 2013
* @since 0.4.0 * @since 0.4.0
*/ */
@RequestProcessor @RequestProcessor
...@@ -94,8 +94,9 @@ public final class UserConsole { ...@@ -94,8 +94,9 @@ public final class UserConsole {
* "oId": "", * "oId": "",
* "userName": "", * "userName": "",
* "userEmail": "", * "userEmail": "",
* "userPassword": "", * "userPassword": "", // Unhashed
* "userRole": "" * "userRole": "", // optional
* "userURL": "", // optional
* } * }
* </pre> * </pre>
* @param context the specified http request context * @param context the specified http request context
...@@ -155,8 +156,8 @@ public final class UserConsole { ...@@ -155,8 +156,8 @@ public final class UserConsole {
* "userName": "", * "userName": "",
* "userEmail": "", * "userEmail": "",
* "userPassword": "", * "userPassword": "",
* "userRole": "" // optional, uses {@value org.b3log.latke.model.Role#DEFAULT_ROLE} instead, * "userURL": "", // optional, uses 'servePath' instead if not specified
* if not speciffied * "userRole": "" // optional, uses {@value org.b3log.latke.model.Role#DEFAULT_ROLE} instead if not speciffied
* } * }
* </pre> * </pre>
* @param response the specified http servlet response * @param response the specified http servlet response
...@@ -176,9 +177,11 @@ public final class UserConsole { ...@@ -176,9 +177,11 @@ public final class UserConsole {
try { try {
final JSONObject requestJSONObject = Requests.parseRequestJSONObject(request, response); final JSONObject requestJSONObject = Requests.parseRequestJSONObject(request, response);
if (userUtils.isAdminLoggedIn(request)) { if (userUtils.isAdminLoggedIn(request)) { // if the administrator register a new user, treats the new user as a normal user
// (defaultRole) who could post article
requestJSONObject.put(User.USER_ROLE, Role.DEFAULT_ROLE); requestJSONObject.put(User.USER_ROLE, Role.DEFAULT_ROLE);
} else { } else { // if a normal user or a visitor register a new user, treates the new user as a visitor (visitorRole) who couldn't
// post article
requestJSONObject.put(User.USER_ROLE, Role.VISITOR_ROLE); requestJSONObject.put(User.USER_ROLE, Role.VISITOR_ROLE);
} }
......
...@@ -437,6 +437,7 @@ public final class InitService { ...@@ -437,6 +437,7 @@ public final class InitService {
admin.put(User.USER_NAME, requestJSONObject.getString(User.USER_NAME)); admin.put(User.USER_NAME, requestJSONObject.getString(User.USER_NAME));
admin.put(User.USER_EMAIL, requestJSONObject.getString(User.USER_EMAIL)); admin.put(User.USER_EMAIL, requestJSONObject.getString(User.USER_EMAIL));
admin.put(User.USER_URL, Latkes.getServePath());
admin.put(User.USER_ROLE, Role.ADMIN_ROLE); admin.put(User.USER_ROLE, Role.ADMIN_ROLE);
admin.put(User.USER_PASSWORD, MD5.hash(requestJSONObject.getString(User.USER_PASSWORD))); admin.put(User.USER_PASSWORD, MD5.hash(requestJSONObject.getString(User.USER_PASSWORD)));
admin.put(UserExt.USER_ARTICLE_COUNT, 0); admin.put(UserExt.USER_ARTICLE_COUNT, 0);
......
...@@ -19,6 +19,7 @@ package org.b3log.solo.service; ...@@ -19,6 +19,7 @@ package org.b3log.solo.service;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import org.b3log.latke.Keys; import org.b3log.latke.Keys;
import org.b3log.latke.Latkes;
import org.b3log.latke.model.Role; import org.b3log.latke.model.Role;
import org.b3log.latke.model.User; import org.b3log.latke.model.User;
import org.b3log.latke.repository.RepositoryException; import org.b3log.latke.repository.RepositoryException;
...@@ -26,6 +27,7 @@ import org.b3log.latke.repository.Transaction; ...@@ -26,6 +27,7 @@ import org.b3log.latke.repository.Transaction;
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.util.MD5; import org.b3log.latke.util.MD5;
import org.b3log.latke.util.Strings;
import org.b3log.solo.model.UserExt; import org.b3log.solo.model.UserExt;
import org.b3log.solo.repository.UserRepository; import org.b3log.solo.repository.UserRepository;
import org.b3log.solo.repository.impl.UserRepositoryImpl; import org.b3log.solo.repository.impl.UserRepositoryImpl;
...@@ -67,7 +69,8 @@ public final class UserMgmtService { ...@@ -67,7 +69,8 @@ public final class UserMgmtService {
* "userName": "", * "userName": "",
* "userEmail": "", * "userEmail": "",
* "userPassword": "", // Unhashed * "userPassword": "", // Unhashed
* "userRole": "" * "userRole": "", // optional
* "userURL": "", // optional
* } * }
* </pre> * </pre>
* @throws ServiceException service exception * @throws ServiceException service exception
...@@ -99,7 +102,18 @@ public final class UserMgmtService { ...@@ -99,7 +102,18 @@ public final class UserMgmtService {
oldUser.put(User.USER_EMAIL, userNewEmail); oldUser.put(User.USER_EMAIL, userNewEmail);
oldUser.put(User.USER_NAME, userName); oldUser.put(User.USER_NAME, userName);
oldUser.put(User.USER_PASSWORD, MD5.hash(userPassword)); oldUser.put(User.USER_PASSWORD, MD5.hash(userPassword));
// Unchanges the default role
final String userRole = requestJSONObject.optString(User.USER_ROLE);
if (!Strings.isEmptyOrNull(userRole)) {
oldUser.put(User.USER_ROLE, userRole);
}
final String userURL = requestJSONObject.optString(User.USER_URL);
if (!Strings.isEmptyOrNull(userURL)) {
oldUser.put(User.USER_URL, userURL);
}
userRepository.update(oldUserId, oldUser); userRepository.update(oldUserId, oldUser);
transaction.commit(); transaction.commit();
...@@ -159,8 +173,8 @@ public final class UserMgmtService { ...@@ -159,8 +173,8 @@ public final class UserMgmtService {
* "userName": "", * "userName": "",
* "userEmail": "", * "userEmail": "",
* "userPassword": "", // Unhashed * "userPassword": "", // Unhashed
* "userRole": "" // optional, uses {@value Role#DEFAULT_ROLE} instead, * "userURL": "", // optional, uses 'servePath' instead if not specified
* if not speciffied * "userRole": "" // optional, uses {@value Role#DEFAULT_ROLE} instead, if not speciffied
* } * }
* </pre>,see {@link User} for more details * </pre>,see {@link User} for more details
* @return generated user id * @return generated user id
...@@ -182,16 +196,32 @@ public final class UserMgmtService { ...@@ -182,16 +196,32 @@ public final class UserMgmtService {
throw new ServiceException(langPropsService.get("duplicatedEmailLabel")); throw new ServiceException(langPropsService.get("duplicatedEmailLabel"));
} }
user.put(User.USER_EMAIL, userEmail);
final String userName = requestJSONObject.optString(User.USER_NAME); final String userName = requestJSONObject.optString(User.USER_NAME);
user.put(User.USER_EMAIL, userEmail);
user.put(User.USER_NAME, userName); user.put(User.USER_NAME, userName);
final String userPassword = requestJSONObject.optString(User.USER_PASSWORD); final String userPassword = requestJSONObject.optString(User.USER_PASSWORD);
user.put(User.USER_PASSWORD, MD5.hash(userPassword)); user.put(User.USER_PASSWORD, MD5.hash(userPassword));
String userURL = requestJSONObject.optString(User.USER_URL);
if (Strings.isEmptyOrNull(userURL)) {
userURL = Latkes.getServePath();
}
if (!Strings.isURL(userURL)) {
throw new ServiceException(langPropsService.get("urlInvalidLabel"));
}
user.put(User.USER_URL, userURL);
final String roleName = requestJSONObject.optString(User.USER_ROLE, Role.DEFAULT_ROLE); final String roleName = requestJSONObject.optString(User.USER_ROLE, Role.DEFAULT_ROLE);
user.put(User.USER_ROLE, roleName); user.put(User.USER_ROLE, roleName);
user.put(UserExt.USER_ARTICLE_COUNT, 0); user.put(UserExt.USER_ARTICLE_COUNT, 0);
user.put(UserExt.USER_PUBLISHED_ARTICLE_COUNT, 0); user.put(UserExt.USER_PUBLISHED_ARTICLE_COUNT, 0);
......
...@@ -17,7 +17,6 @@ package org.b3log.solo.util; ...@@ -17,7 +17,6 @@ package org.b3log.solo.util;
import java.io.IOException; import java.io.IOException;
import java.net.URL;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import org.b3log.latke.Keys; import org.b3log.latke.Keys;
...@@ -41,7 +40,7 @@ import org.json.JSONObject; ...@@ -41,7 +40,7 @@ import org.json.JSONObject;
* Comment utilities. * Comment utilities.
* *
* @author <a href="mailto:DL88250@gmail.com">Liang Ding</a> * @author <a href="mailto:DL88250@gmail.com">Liang Ding</a>
* @version 1.0.0.9, Mar 28, 2012 * @version 1.0.0.10, Apr 2, 2013
* @since 0.3.1 * @since 0.3.1
*/ */
public final class Comments { public final class Comments {
...@@ -204,13 +203,7 @@ public final class Comments { ...@@ -204,13 +203,7 @@ public final class Comments {
final String commentURL = requestJSONObject.optString(Comment.COMMENT_URL); final String commentURL = requestJSONObject.optString(Comment.COMMENT_URL);
try { if (!Strings.isURL(commentURL)) {
new URL(commentURL);
if (commentURL.contains("<") || commentURL.contains(">")) {
throw new IllegalArgumentException();
}
} catch (final Exception e) {
LOGGER.log(Level.WARNING, "Comment URL is invalid[{0}]", commentURL); LOGGER.log(Level.WARNING, "Comment URL is invalid[{0}]", commentURL);
ret.put(Keys.MSG, langPropsService.get("urlInvalidLabel")); ret.put(Keys.MSG, langPropsService.get("urlInvalidLabel"));
......
{ {
"description": "Description of repository structures, for generation (DDL: http://en.wikipedia.org/wiki/Data_Definition_Language) of the relational database table and persistence validation.", "description": "Description of repository structures, for generation (DDL: http://en.wikipedia.org/wiki/Data_Definition_Language) of the relational database table and persistence validation.",
"version": "1.0.0.9, Mar 5, 2013", "version": "1.0.1.0, Apr 2, 2013",
"authors": ["Liang Ding"], "authors": ["Liang Ding"],
"since": "0.4.0", "since": "0.4.0",
...@@ -538,6 +538,11 @@ ...@@ -538,6 +538,11 @@
"type": "String", "type": "String",
"length": 255 "length": 255
}, },
{
"name": "userURL",
"type": "String",
"length": 255
},
{ {
"name": "userPassword", "name": "userPassword",
"type": "String", "type": "String",
......
...@@ -34,7 +34,7 @@ import org.testng.annotations.Test; ...@@ -34,7 +34,7 @@ import org.testng.annotations.Test;
* {@link UserRepositoryImpl} test case. * {@link UserRepositoryImpl} test case.
* *
* @author <a href="mailto:DL88250@gmail.com">Liang Ding</a> * @author <a href="mailto:DL88250@gmail.com">Liang Ding</a>
* @version 1.0.0.1, Feb 21, 2012 * @version 1.0.0.2, Apr 2, 2013
*/ */
@Test(suiteName = "repository") @Test(suiteName = "repository")
public final class UserRepositoryImplTestCase extends AbstractTestCase { public final class UserRepositoryImplTestCase extends AbstractTestCase {
...@@ -52,6 +52,7 @@ public final class UserRepositoryImplTestCase extends AbstractTestCase { ...@@ -52,6 +52,7 @@ public final class UserRepositoryImplTestCase extends AbstractTestCase {
another.put(User.USER_NAME, "test1"); another.put(User.USER_NAME, "test1");
another.put(User.USER_EMAIL, "test1@gmail.com"); another.put(User.USER_EMAIL, "test1@gmail.com");
another.put(User.USER_PASSWORD, "pass1"); another.put(User.USER_PASSWORD, "pass1");
another.put(User.USER_URL, "http://b3log.org");
another.put(User.USER_ROLE, Role.DEFAULT_ROLE); another.put(User.USER_ROLE, Role.DEFAULT_ROLE);
another.put(UserExt.USER_ARTICLE_COUNT, 0); another.put(UserExt.USER_ARTICLE_COUNT, 0);
another.put(UserExt.USER_PUBLISHED_ARTICLE_COUNT, 0); another.put(UserExt.USER_PUBLISHED_ARTICLE_COUNT, 0);
...@@ -66,6 +67,7 @@ public final class UserRepositoryImplTestCase extends AbstractTestCase { ...@@ -66,6 +67,7 @@ public final class UserRepositoryImplTestCase extends AbstractTestCase {
admin.put(User.USER_NAME, "test"); admin.put(User.USER_NAME, "test");
admin.put(User.USER_EMAIL, "test@gmail.com"); admin.put(User.USER_EMAIL, "test@gmail.com");
admin.put(User.USER_PASSWORD, "pass"); admin.put(User.USER_PASSWORD, "pass");
admin.put(User.USER_URL, "http://b3log.org");
admin.put(User.USER_ROLE, Role.ADMIN_ROLE); admin.put(User.USER_ROLE, Role.ADMIN_ROLE);
admin.put(UserExt.USER_ARTICLE_COUNT, 0); admin.put(UserExt.USER_ARTICLE_COUNT, 0);
admin.put(UserExt.USER_PUBLISHED_ARTICLE_COUNT, 0); admin.put(UserExt.USER_PUBLISHED_ARTICLE_COUNT, 0);
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
# #
# Description: B3log Solo language configurations(en_US). # Description: B3log Solo language configurations(en_US).
# Version: 2.1.0.6, Apr 1, 2013 # Version: 2.1.0.7, Apr 2, 2013
# Author: Liang Ding # Author: Liang Ding
# Author: Liyuan Li # Author: Liyuan Li
# Author: Dongxu Wang # Author: Dongxu Wang
...@@ -193,6 +193,8 @@ userName1Label=Username: ...@@ -193,6 +193,8 @@ userName1Label=Username:
userLabel=User userLabel=User
userPassword1Label=Password: userPassword1Label=Password:
userPasswordLabel=Password userPasswordLabel=Password
userURL1Label=Link:
userURLLabel=Link
categoryLabel=Category categoryLabel=Category
noticeBoard1Label=Notice Board: noticeBoard1Label=Notice Board:
noticeBoardLabel=Notice Board noticeBoardLabel=Notice Board
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
# #
# Description: B3log Solo default language configurations(zh_CN). # Description: B3log Solo default language configurations(zh_CN).
# Version: 2.1.1.3, Apr 1, 2013 # Version: 2.1.1.4, Apr 2, 2013
# Author: Liang Ding # Author: Liang Ding
# Author: Liyuan Li # Author: Liyuan Li
# Author: Dongxu Wang # Author: Dongxu Wang
...@@ -193,6 +193,8 @@ userName1Label=\u7528\u6237\u540d\uff1a ...@@ -193,6 +193,8 @@ userName1Label=\u7528\u6237\u540d\uff1a
userLabel=\u7528\u6237 userLabel=\u7528\u6237
userPassword1Label=\u5bc6\u7801\uff1a userPassword1Label=\u5bc6\u7801\uff1a
userPasswordLabel=\u5bc6\u7801 userPasswordLabel=\u5bc6\u7801
userURL1Label=\u94fe\u63a5\uff1a
userURLLabel=\u94fe\u63a5
categoryLabel=\u5206\u7c7b categoryLabel=\u5206\u7c7b
noticeBoard1Label=\u516c\u544a\uff1a noticeBoard1Label=\u516c\u544a\uff1a
noticeBoardLabel=\u516c\u544a noticeBoardLabel=\u516c\u544a
......
...@@ -26,6 +26,14 @@ ...@@ -26,6 +26,14 @@
<input id="userEmail" type="text"/> <input id="userEmail" type="text"/>
</td> </td>
</tr> </tr>
<tr>
<th>
<label for="userURL">${userURL1Label}</label>
</th>
<td>
<input id="userURL" type="text"/>
</td>
</tr>
<tr> <tr>
<th> <th>
<label for="userPassword">${userPassword1Label}</label> <label for="userPassword">${userPassword1Label}</label>
...@@ -67,6 +75,14 @@ ...@@ -67,6 +75,14 @@
<input id="userEmailUpdate" type="text"/> <input id="userEmailUpdate" type="text"/>
</td> </td>
</tr> </tr>
<tr>
<th>
<label for="userURLUpdate">${userURL1Label}</label>
</th>
<td>
<input id="userURLUpdate" type="text"/>
</td>
</tr>
<tr> <tr>
<th> <th>
<label for="userPasswordUpdate">${userPassword1Label}</label> <label for="userPasswordUpdate">${userPassword1Label}</label>
......
...@@ -134,6 +134,7 @@ admin.userList = { ...@@ -134,6 +134,7 @@ admin.userList = {
var requestJSONObject = { var requestJSONObject = {
"userName": $("#userName").val(), "userName": $("#userName").val(),
"userEmail": $("#userEmail").val(), "userEmail": $("#userEmail").val(),
"userURL": $("#userURL").val(),
"userPassword": $("#userPassword").val() "userPassword": $("#userPassword").val()
}; };
...@@ -151,6 +152,7 @@ admin.userList = { ...@@ -151,6 +152,7 @@ admin.userList = {
$("#userName").val(""); $("#userName").val("");
$("#userEmail").val(""); $("#userEmail").val("");
$("#userURL").val("");
$("#userPassword").val(""); $("#userPassword").val("");
if (admin.userList.pageInfo.currentCount === Label.PAGE_SIZE && if (admin.userList.pageInfo.currentCount === Label.PAGE_SIZE &&
admin.userList.pageInfo.currentPage === admin.userList.pageInfo.pageCount) { admin.userList.pageInfo.currentPage === admin.userList.pageInfo.pageCount) {
...@@ -198,6 +200,8 @@ admin.userList = { ...@@ -198,6 +200,8 @@ admin.userList = {
} else { } else {
$userEmailUpdate.removeAttr("disabled"); $userEmailUpdate.removeAttr("disabled");
} }
$("#userURLUpdate").val(result.user.userURL);
$("#userPasswordUpdate").val(result.user.userPassword); $("#userPasswordUpdate").val(result.user.userPassword);
$("#loadMsg").text(""); $("#loadMsg").text("");
...@@ -217,6 +221,7 @@ admin.userList = { ...@@ -217,6 +221,7 @@ admin.userList = {
"userName": $("#userNameUpdate").val(), "userName": $("#userNameUpdate").val(),
"oId": userInfo.oId, "oId": userInfo.oId,
"userEmail": $("#userEmailUpdate").val(), "userEmail": $("#userEmailUpdate").val(),
"userURL": $("#userURLUpdate").val(),
"userRole": userInfo.userRole, "userRole": userInfo.userRole,
"userPassword": $("#userPasswordUpdate").val() "userPassword": $("#userPasswordUpdate").val()
}; };
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<meta charset="utf-8" /> <meta charset="utf-8" />
<title>${blogTitle}</title> <title>${blogTitle}</title>
<meta name="keywords" content="GAE 博客,blog,b3log,kill IE6" /> <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="description" content="An open source blog based on GAE Java,GAE Java 开源博客,用户注册" />
<meta name="owner" content="B3log Team" /> <meta name="owner" content="B3log Team" />
<meta name="author" content="B3log Team" /> <meta name="author" content="B3log Team" />
<meta name="generator" content="B3log Solo" /> <meta name="generator" content="B3log Solo" />
...@@ -34,6 +34,10 @@ ...@@ -34,6 +34,10 @@
${userName1Label} ${userName1Label}
</label> </label>
<input id="userName" /> <input id="userName" />
<label for="userURL">
${userURL1Label}
</label>
<input id="userURL" />
<label for="userPassword"> <label for="userPassword">
${userPassword1Label} ${userPassword1Label}
</label> </label>
...@@ -89,6 +93,7 @@ ...@@ -89,6 +93,7 @@
var requestJSONObject = { var requestJSONObject = {
"userName": $("#userName").val(), "userName": $("#userName").val(),
"userEmail": $("#userEmail").val(), "userEmail": $("#userEmail").val(),
"userURL": $("#userURL").val(),
"userPassword": $("#userPassword").val() "userPassword": $("#userPassword").val()
}; };
$.ajax({ $.ajax({
......
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