From 5e346c6d72b7776ed911d742861d9a57ec0d88b5 Mon Sep 17 00:00:00 2001 From: thinkgem Date: Tue, 29 Sep 2020 16:07:38 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=BE=E5=9B=9E=E5=AF=86=E7=A0=81=E5=92=8C?= =?UTF-8?q?=E6=B3=A8=E5=86=8C=E7=94=A8=E6=88=B7=E6=95=8F=E6=84=9F=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E5=8A=A0=E5=AF=86=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/sys/web/AccountController.java | 25 ++++++++++++++--- .../modules/sys/web/LoginController.java | 3 +-- .../main/resources/config/jeesite-core.yml | 2 +- .../resources/static/modules/sys/forgetPwd.js | 19 ++++++++++++- .../static/modules/sys/registerUser.js | 13 ++++++++- .../views/modules/sys/forgetPwd.html | 18 ++++++------- .../views/modules/sys/registerUser.html | 4 ++- .../views/modules/sys/user/userInfo.html | 27 ++++++++++--------- web/src/main/resources/config/application.yml | 2 +- 9 files changed, 81 insertions(+), 32 deletions(-) diff --git a/modules/core/src/main/java/com/jeesite/modules/sys/web/AccountController.java b/modules/core/src/main/java/com/jeesite/modules/sys/web/AccountController.java index afb8867b..e1fb65e1 100644 --- a/modules/core/src/main/java/com/jeesite/modules/sys/web/AccountController.java +++ b/modules/core/src/main/java/com/jeesite/modules/sys/web/AccountController.java @@ -19,6 +19,7 @@ import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; +import com.jeesite.common.codec.DesUtils; import com.jeesite.common.collect.MapUtils; import com.jeesite.common.config.Global; import com.jeesite.common.lang.StringUtils; @@ -145,13 +146,17 @@ public class AccountController extends BaseController{ if (s != null) { return s; } + String secretKey = Global.getProperty("shiro.loginSubmit.secretKey"); + if (StringUtils.isNotBlank(secretKey)){ + user.setPassword(DesUtils.decode(user.getPassword(), secretKey)); + } // 更新为新密码 try{ userService.updatePassword(userCode, user.getPassword()); }catch(ServiceException se){ return renderResult(Global.FALSE, se.getMessage()); } - return renderResult(Global.TRUE, text("恭喜你,您的账号 {0} 密码修改成功!", user.getUserCode())); + return renderResult(Global.TRUE, text("恭喜你,您的账号 {0} 密码找回成功!", user.getLoginCode())); } /** @@ -299,6 +304,14 @@ public class AccountController extends BaseController{ return renderResult(Global.FALSE, text("请重新获取保密问题!")); } + String secretKey = Global.getProperty("shiro.loginSubmit.secretKey"); + if (StringUtils.isNotBlank(secretKey)){ + user.setPwdQuestionAnswer(DesUtils.decode(user.getPwdQuestionAnswer(), secretKey)); + user.setPwdQuestionAnswer2(DesUtils.decode(user.getPwdQuestionAnswer2(), secretKey)); + user.setPwdQuestionAnswer3(DesUtils.decode(user.getPwdQuestionAnswer3(), secretKey)); + user.setPassword(DesUtils.decode(user.getPassword(), secretKey)); + } + // 验证三个密保问题是否正确。 User u = UserUtils.getByLoginCode(user.getLoginCode()); if (!(u != null && loginCode.equals(user.getLoginCode()) @@ -318,8 +331,8 @@ public class AccountController extends BaseController{ // 更新密码后,清理缓存 UserUtils.removeCache("fpUserCode"); UserUtils.removeCache("fpLoginCode"); - - return renderResult(Global.TRUE, text("验证通过")); + + return renderResult(Global.TRUE, text("恭喜你,您的账号 {0} 密码找回成功!", user.getLoginCode())); } /** @@ -466,6 +479,10 @@ public class AccountController extends BaseController{ } u.setLoginCode(loginCode); u.setUserName(userName); + String secretKey = Global.getProperty("shiro.loginSubmit.secretKey"); + if (StringUtils.isNotBlank(secretKey)){ + user.setPassword(DesUtils.decode(user.getPassword(), secretKey)); + } u.setPassword(user.getPassword()); u.setEmail(email); u.setMobile(mobile); @@ -483,7 +500,7 @@ public class AccountController extends BaseController{ UserUtils.removeCache("regValidCode"); UserUtils.removeCache("regLastDate"); - return renderResult(Global.TRUE, text("恭喜你,您的账号 "+u.getLoginCode()+" 注册成功!")); + return renderResult(Global.TRUE, text("恭喜你,您的账号 {0} 注册成功!", u.getLoginCode())); } /** diff --git a/modules/core/src/main/java/com/jeesite/modules/sys/web/LoginController.java b/modules/core/src/main/java/com/jeesite/modules/sys/web/LoginController.java index 7e354878..7ae12e42 100644 --- a/modules/core/src/main/java/com/jeesite/modules/sys/web/LoginController.java +++ b/modules/core/src/main/java/com/jeesite/modules/sys/web/LoginController.java @@ -18,7 +18,6 @@ import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody; import com.fasterxml.jackson.annotation.JsonView; @@ -46,7 +45,7 @@ public class LoginController extends BaseController{ /** * 登录页面 */ - @RequestMapping(value = "login", method = RequestMethod.GET) + @RequestMapping(value = "login") public String login(HttpServletRequest request, HttpServletResponse response, Model model) { // 地址中如果包含JSESSIONID,则跳转一次,去掉JSESSIONID信息。 if (StringUtils.containsIgnoreCase(request.getRequestURI(), ";JSESSIONID=")){ diff --git a/modules/core/src/main/resources/config/jeesite-core.yml b/modules/core/src/main/resources/config/jeesite-core.yml index 11995b6b..cf911445 100644 --- a/modules/core/src/main/resources/config/jeesite-core.yml +++ b/modules/core/src/main/resources/config/jeesite-core.yml @@ -371,7 +371,7 @@ shiro: # accessControlAllowOrigin: http://demo.jeesite.com # accessControlAllowOrigin: '*' - # 允许跨域访问时 CORS,可以使用的方法和响应头 + # 允许跨域访问时 CORS,可以使用的方法和标头 # accessControlAllowMethods: GET, POST, OPTIONS # accessControlAllowHeaders: Origin, No-Cache, X-Requested-With, If-Modified-Since, Pragma, Last-Modified, Cache-Control, Expires, Content-Type, X-E4M-With diff --git a/modules/core/src/main/resources/static/modules/sys/forgetPwd.js b/modules/core/src/main/resources/static/modules/sys/forgetPwd.js index e0edf756..c2061963 100644 --- a/modules/core/src/main/resources/static/modules/sys/forgetPwd.js +++ b/modules/core/src/main/resources/static/modules/sys/forgetPwd.js @@ -75,7 +75,24 @@ $(function(){ $('#forgetForm').validate({ ignore: ":hidden", submitHandler: function(form) { - js.ajaxSubmitForm($(form), function(data){ + var $form = $(form), + action = $form.attr('action'), + data = $form.serializeArray(), + key = window.secretKey||$('#loginKey').data('key'); + if (key != ''){ + for (var i=0, l=data.length; i
- +
问题2:
- +
问题3:
- +
设置新密码: @@ -93,11 +93,11 @@
<% } %> - - + \ No newline at end of file diff --git a/modules/core/src/main/resources/views/modules/sys/registerUser.html b/modules/core/src/main/resources/views/modules/sys/registerUser.html index 4d6b8554..6e5d1b59 100644 --- a/modules/core/src/main/resources/views/modules/sys/registerUser.html +++ b/modules/core/src/main/resources/views/modules/sys/registerUser.html @@ -89,9 +89,11 @@ <% } %> + \ No newline at end of file diff --git a/modules/core/src/main/resources/views/modules/sys/user/userInfo.html b/modules/core/src/main/resources/views/modules/sys/user/userInfo.html index 070251a6..821979cc 100644 --- a/modules/core/src/main/resources/views/modules/sys/user/userInfo.html +++ b/modules/core/src/main/resources/views/modules/sys/user/userInfo.html @@ -311,16 +311,22 @@ $('#sex input').on('ifCreated ifChecked', function(){ $("#newPassword").strength(); $("#inputFormPwd").validate({ submitHandler: function(form){ - var oldPassword = $('#oldPassword').val(), - newPassword = $('#newPassword').val(), - confirmNewPassword = $('#confirmNewPassword').val(), - secretKey = '${@Global.getConfig("shiro.loginSubmit.secretKey")}'; - if (secretKey != ''){ - $('#oldPassword').val(DesUtils.encode(oldPassword, secretKey)); - $('#newPassword').val(DesUtils.encode(newPassword, secretKey)); - $('#confirmNewPassword').val(DesUtils.encode(confirmNewPassword, secretKey)); + var $form = $(form), + action = $form.attr('action'), + data = $form.serializeArray(), + key = '${@Global.getConfig("shiro.loginSubmit.secretKey")}'; + if (key != ''){ + for (var i=0, l=data.length; i