Commit d1481b56 authored by Liang Ding's avatar Liang Ding
parent c1b2e062
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
*/ */
package org.b3log.solo.processor; package org.b3log.solo.processor;
import org.b3log.latke.Keys; import org.b3log.latke.Keys;
import org.b3log.latke.Latkes; import org.b3log.latke.Latkes;
import org.b3log.latke.ioc.inject.Inject; import org.b3log.latke.ioc.inject.Inject;
...@@ -59,7 +58,6 @@ import java.io.IOException; ...@@ -59,7 +58,6 @@ import java.io.IOException;
import java.util.Calendar; import java.util.Calendar;
import java.util.Map; import java.util.Map;
/** /**
* Login/logout processor. * Login/logout processor.
* *
...@@ -351,23 +349,23 @@ public class LoginProcessor { ...@@ -351,23 +349,23 @@ public class LoginProcessor {
final JSONObject requestJSONObject; final JSONObject requestJSONObject;
requestJSONObject = Requests.parseRequestJSONObject(request, context.getResponse()); requestJSONObject = Requests.parseRequestJSONObject(request, context.getResponse());
final String token = requestJSONObject.getString("token"); final String token = requestJSONObject.getString("token");
final String newPwd = requestJSONObject.getString("newPwd"); final String newPwd = requestJSONObject.getString("newPwd");
final JSONObject passwordResetOption = optionQueryService.getOptionById(token); final JSONObject passwordResetOption = optionQueryService.getOptionById(token);
if (null == passwordResetOption) { if (null == passwordResetOption) {
LOGGER.log(Level.WARN, "Not found user by that token:[{0}]", token); LOGGER.log(Level.WARN, "Not found user by that token:[{0}]", token);
jsonObject.put("succeed", true); jsonObject.put("succeed", true);
jsonObject.put("to", Latkes.getServePath() + "/login?from=reset"); jsonObject.put("to", Latkes.getServePath() + "/login?from=reset");
jsonObject.put(Keys.MSG, langPropsService.get("resetPwdFailedMsg")); jsonObject.put(Keys.MSG, langPropsService.get("resetPwdFailedMsg"));
return; return;
} }
final String userEmail = passwordResetOption.getString(Option.OPTION_VALUE); final String userEmail = passwordResetOption.getString(Option.OPTION_VALUE);
final JSONObject user = userQueryService.getUserByEmail(userEmail); final JSONObject user = userQueryService.getUserByEmail(userEmail);
user.put(User.USER_PASSWORD, newPwd); user.put(User.USER_PASSWORD, newPwd);
userMgmtService.updateUser(user); userMgmtService.updateUser(user);
// TODO delete expired token // TODO delete expired token
LOGGER.log(Level.DEBUG, "[{0}]'s password updated successfully.", userEmail); LOGGER.log(Level.DEBUG, "[{0}]'s password updated successfully.", userEmail);
jsonObject.put("succeed", true); jsonObject.put("succeed", true);
...@@ -403,17 +401,17 @@ public class LoginProcessor { ...@@ -403,17 +401,17 @@ public class LoginProcessor {
final String token = new Randoms().nextStringWithMD5(); final String token = new Randoms().nextStringWithMD5();
final String adminEmail = preference.getString(Option.ID_C_ADMIN_EMAIL); final String adminEmail = preference.getString(Option.ID_C_ADMIN_EMAIL);
final String mailSubject = langPropsService.get("resetPwdMailSubject"); final String mailSubject = langPropsService.get("resetPwdMailSubject");
final String mailBody = langPropsService.get("resetPwdMailBody") + " " + Latkes.getServePath() final String mailBody = langPropsService.get("resetPwdMailBody") + " " + Latkes.getServePath()
+ "/forgot?token=" + token; + "/forgot?token=" + token;
final MailService.Message message = new MailService.Message(); final MailService.Message message = new MailService.Message();
final JSONObject option = new JSONObject(); final JSONObject option = new JSONObject();
option.put(Keys.OBJECT_ID, token); option.put(Keys.OBJECT_ID, token);
option.put(Option.OPTION_CATEGORY, "passwordReset"); option.put(Option.OPTION_CATEGORY, "passwordReset");
option.put(Option.OPTION_VALUE, userEmail); option.put(Option.OPTION_VALUE, userEmail);
final Transaction transaction = optionRepository.beginTransaction(); final Transaction transaction = optionRepository.beginTransaction();
optionRepository.add(option); optionRepository.add(option);
transaction.commit(); transaction.commit();
message.setFrom(adminEmail); message.setFrom(adminEmail);
...@@ -470,7 +468,7 @@ public class LoginProcessor { ...@@ -470,7 +468,7 @@ public class LoginProcessor {
} else { } else {
// TODO verify the expired time in the tokenObj // TODO verify the expired time in the tokenObj
dataModel.put("inputType", "password"); dataModel.put("inputType", "password");
dataModel.put("tokenHidden", token); dataModel.put("tokenHidden", token);
} }
final String from = request.getParameter("from"); final String from = request.getParameter("from");
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
# #
# Description: Solo language configurations(en_US). # Description: Solo language configurations(en_US).
# Version: 2.16.0.0, Jul 3, 2017 # Version: 2.16.0.0, Aug 8, 2017
# Author: Liang Ding # Author: Liang Ding
# Author: Liyuan Li # Author: Liyuan Li
# Author: Dongxu Wang # Author: Dongxu Wang
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
# #
# Description: Solo default language configurations(zh_CN). # Description: Solo default language configurations(zh_CN).
# Version: 2.16.0.0, Jul 3, 2017 # Version: 2.17.0.0, Aug 8, 2017
# Author: Liang Ding # Author: Liang Ding
# Author: Liyuan Li # Author: Liyuan Li
# Author: Dongxu Wang # Author: Dongxu Wang
...@@ -298,7 +298,7 @@ forgotLabel=\u5FD8\u8BB0\u5BC6\u7801 ...@@ -298,7 +298,7 @@ forgotLabel=\u5FD8\u8BB0\u5BC6\u7801
sendLabel=\u53D1\u9001 sendLabel=\u53D1\u9001
userEmailNotFoundMsg=\u90AE\u7BB1\u5730\u5740\u6709\u8BEF\uFF0C\u8BF7\u91CD\u8BD5 userEmailNotFoundMsg=\u90AE\u7BB1\u5730\u5740\u6709\u8BEF\uFF0C\u8BF7\u91CD\u8BD5
resetPwdSuccessMsg=\u5BC6\u7801\u4FEE\u6539\u6210\u529F resetPwdSuccessMsg=\u5BC6\u7801\u4FEE\u6539\u6210\u529F
resetPwdFailedMsg=\u4e0d\u80fd\u6839\u636e\u6b64token\u627e\u5230\u6709\u6548\u90ae\u7bb1\u4fe1\u606f resetPwdFailedMsg=\u4E0D\u80FD\u6839\u636E\u6B64 token \u627E\u5230\u6709\u6548\u7684\u90AE\u7BB1
resetPwdSuccessSend=\u66F4\u6539\u5BC6\u7801\u7684\u786E\u8BA4\u94FE\u63A5\u5DF2\u53D1\u9001\u81F3\u6307\u5B9A\u90AE\u7BB1 resetPwdSuccessSend=\u66F4\u6539\u5BC6\u7801\u7684\u786E\u8BA4\u94FE\u63A5\u5DF2\u53D1\u9001\u81F3\u6307\u5B9A\u90AE\u7BB1
resetPwdMailSubject=[Solo]\u91CD\u7F6E\u5BC6\u7801 resetPwdMailSubject=[Solo]\u91CD\u7F6E\u5BC6\u7801
resetPwdMailBody=\u60F3\u66F4\u6539\u5BC6\u7801\uFF0C\u8BF7\u6253\u5F00\u4E0B\u9762\u94FE\u63A5\uFF1B\u82E5\u4E0D\u60F3\u4FEE\u6539\uFF0C\u53EA\u8981\u5FFD\u7565\u6B64\u6B21\u90AE\u4EF6\uFF0C\u7CFB\u7EDF\u5E76\u4E0D\u4F1A\u81EA\u52A8\u4FEE\u6539\u60A8\u7684\u5BC6\u7801\u3002<p> resetPwdMailBody=\u60F3\u66F4\u6539\u5BC6\u7801\uFF0C\u8BF7\u6253\u5F00\u4E0B\u9762\u94FE\u63A5\uFF1B\u82E5\u4E0D\u60F3\u4FEE\u6539\uFF0C\u53EA\u8981\u5FFD\u7565\u6B64\u6B21\u90AE\u4EF6\uFF0C\u7CFB\u7EDF\u5E76\u4E0D\u4F1A\u81EA\u52A8\u4FEE\u6539\u60A8\u7684\u5BC6\u7801\u3002<p>
......
...@@ -19,7 +19,7 @@ ${forgotLabel} ...@@ -19,7 +19,7 @@ ${forgotLabel}
${userPasswordLabel} ${userPasswordLabel}
</label> </label>
<input type="password" id="emailOrPassword"/> <input type="password" id="emailOrPassword"/>
<input type="hidden" id="token" value="${tokenHidden}" /> <input type="hidden" id="token" value="${tokenHidden}"/>
<button id="sendBtn" onclick='reset();'>${ok}</button> <button id="sendBtn" onclick='reset();'>${ok}</button>
<span id="tip"></span> <span id="tip"></span>
</div> </div>
...@@ -27,10 +27,10 @@ ${forgotLabel} ...@@ -27,10 +27,10 @@ ${forgotLabel}
<script type="text/javascript" src="${staticServePath}/js/lib/jquery/jquery.min.js" charset="utf-8"></script> <script type="text/javascript" src="${staticServePath}/js/lib/jquery/jquery.min.js" charset="utf-8"></script>
<script type="text/javascript"> <script type="text/javascript">
(function() { (function () {
$("#emailOrPassword").focus(); $("#emailOrPassword").focus();
$("#emailOrPassword").keypress(function(event) { $("#emailOrPassword").keypress(function (event) {
if (13 === event.keyCode) { // Enter pressed if (13 === event.keyCode) { // Enter pressed
$('#sendBtn').click(); $('#sendBtn').click();
} }
...@@ -44,7 +44,7 @@ ${forgotLabel} ...@@ -44,7 +44,7 @@ ${forgotLabel}
} }
})(); })();
var reset = function() { var reset = function () {
if ($("#emailOrPassword").val() === "") { if ($("#emailOrPassword").val() === "") {
$("#tip").text("${passwordEmptyLabel}"); $("#tip").text("${passwordEmptyLabel}");
$("#emailOrPassword").focus(); $("#emailOrPassword").focus();
...@@ -61,10 +61,10 @@ ${forgotLabel} ...@@ -61,10 +61,10 @@ ${forgotLabel}
type: "POST", type: "POST",
contentType: "application/json", contentType: "application/json",
data: JSON.stringify(requestJSONObject), data: JSON.stringify(requestJSONObject),
error: function() { error: function () {
// alert("reset password error!"); // alert("reset password error!");
}, },
success: function(data, textStatus) { success: function (data, textStatus) {
if (data.succeed) { if (data.succeed) {
window.location.href = data.to; window.location.href = data.to;
} else { } else {
...@@ -74,7 +74,7 @@ ${forgotLabel} ...@@ -74,7 +74,7 @@ ${forgotLabel}
}); });
}; };
var forgot = function() { var forgot = function () {
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($("#emailOrPassword" + status).val())) { 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($("#emailOrPassword" + status).val())) {
$("#tip").text("${mailInvalidLabel}"); $("#tip").text("${mailInvalidLabel}");
$("#emailOrPassword").focus(); $("#emailOrPassword").focus();
...@@ -91,10 +91,10 @@ ${forgotLabel} ...@@ -91,10 +91,10 @@ ${forgotLabel}
type: "POST", type: "POST",
contentType: "application/json", contentType: "application/json",
data: JSON.stringify(requestJSONObject), data: JSON.stringify(requestJSONObject),
error: function() { error: function () {
// alert("reset password error!"); // alert("reset password error!");
}, },
success: function(data, textStatus) { success: function (data, textStatus) {
if (data.succeed) { if (data.succeed) {
window.location.href = data.to; window.location.href = data.to;
} else { } else {
......
This diff is collapsed.
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