作者 shenhailong

添加普通用户修改密码 shiro版本

@@ -30,7 +30,7 @@ @@ -30,7 +30,7 @@
30 <commons-lang3.version>3.4</commons-lang3.version> 30 <commons-lang3.version>3.4</commons-lang3.version>
31 <commons-fileupload.version>1.3.1</commons-fileupload.version> 31 <commons-fileupload.version>1.3.1</commons-fileupload.version>
32 <commons-codec.version>1.10</commons-codec.version> 32 <commons-codec.version>1.10</commons-codec.version>
33 - <shiro.version>1.2.3</shiro.version> 33 + <shiro.version>1.4.0</shiro.version>
34 <cxf.version>2.7.5</cxf.version> 34 <cxf.version>2.7.5</cxf.version>
35 <patchca.version>0.5.0</patchca.version> 35 <patchca.version>0.5.0</patchca.version>
36 <jxl.version>2.6.12</jxl.version> 36 <jxl.version>2.6.12</jxl.version>
@@ -330,6 +330,7 @@ @@ -330,6 +330,7 @@
330 <version>${patchca.version}</version> 330 <version>${patchca.version}</version>
331 </dependency> 331 </dependency>
332 332
  333 +
333 <!-- oracle jdbc 驱动 --> 334 <!-- oracle jdbc 驱动 -->
334 <dependency> 335 <dependency>
335 <groupId>com.oracle</groupId> 336 <groupId>com.oracle</groupId>
@@ -337,6 +338,7 @@ @@ -337,6 +338,7 @@
337 <version>11.2.0.4.0-atlassian-hosted</version> 338 <version>11.2.0.4.0-atlassian-hosted</version>
338 </dependency> 339 </dependency>
339 340
  341 +
340 <dependency> 342 <dependency>
341 <groupId>net.sourceforge.jexcelapi</groupId> 343 <groupId>net.sourceforge.jexcelapi</groupId>
342 <artifactId>jxl</artifactId> 344 <artifactId>jxl</artifactId>
@@ -28,7 +28,6 @@ import com.agent.service.system.UserService; @@ -28,7 +28,6 @@ import com.agent.service.system.UserService;
28 import com.agent.vo.ResponseModel; 28 import com.agent.vo.ResponseModel;
29 import com.agent.vo.agent.UserVo; 29 import com.agent.vo.agent.UserVo;
30 import com.framework.core.Servlets; 30 import com.framework.core.Servlets;
31 -import com.framework.shiro.SessionUtil;  
32 import com.framework.util.MD5Tools; 31 import com.framework.util.MD5Tools;
33 import com.plugin.easyui.DataGrid; 32 import com.plugin.easyui.DataGrid;
34 import com.plugin.easyui.EasyPage; 33 import com.plugin.easyui.EasyPage;
@@ -186,6 +185,18 @@ public class UserController extends BasicController { @@ -186,6 +185,18 @@ public class UserController extends BasicController {
186 185
187 return "system/user/changepassword"; 186 return "system/user/changepassword";
188 } 187 }
  188 +
  189 +
  190 + @RequestMapping(value = "/commonPassword")
  191 + public String commonPassword(Long id, Model model){
  192 +
  193 + model.addAttribute("userid", id);
  194 +
  195 + return "system/user/commonpassword";
  196 +
  197 + }
  198 +
  199 +
189 /** 200 /**
190 * 验证原密码密码 201 * 验证原密码密码
191 * @return 202 * @return
@@ -201,7 +212,7 @@ public class UserController extends BasicController { @@ -201,7 +212,7 @@ public class UserController extends BasicController {
201 model.setStatus(200); 212 model.setStatus(200);
202 model.setMsg("验证通过"); 213 model.setMsg("验证通过");
203 }else{ 214 }else{
204 - model.setStatus(500); 215 + model.setStatus(501);
205 model.setMsg("验证失败"); 216 model.setMsg("验证失败");
206 } 217 }
207 } catch (Exception e) { 218 } catch (Exception e) {
@@ -228,7 +239,7 @@ public class UserController extends BasicController { @@ -228,7 +239,7 @@ public class UserController extends BasicController {
228 model.setStatus(200); 239 model.setStatus(200);
229 model.setMsg("修改成功"); 240 model.setMsg("修改成功");
230 }else{ 241 }else{
231 - model.setStatus(500); 242 + model.setStatus(501);
232 model.setMsg("您的两次密码不一致"); 243 model.setMsg("您的两次密码不一致");
233 } 244 }
234 } catch (Exception e) { 245 } catch (Exception e) {
@@ -16,6 +16,7 @@ import java.awt.image.BufferedImage; @@ -16,6 +16,7 @@ import java.awt.image.BufferedImage;
16 import java.io.IOException; 16 import java.io.IOException;
17 17
18 @RestController 18 @RestController
  19 +@RequestMapping("/agent")
19 public class VerifyCodeController extends HttpServlet{ 20 public class VerifyCodeController extends HttpServlet{
20 21
21 /** 22 /**
@@ -32,10 +32,15 @@ @@ -32,10 +32,15 @@
32 </select> 32 </select>
33 </div> 33 </div>
34 34
  35 + <div style="height:70px;line-height: 70px;width: 100px;float: right;">
  36 + <h4 style="min-width:32px; color: #FFFFFF;"><span onclick="changepassword('${user.id}')">修改密码</span></h4>
  37 + </div>
  38 +
35 <div class="pf-user"> 39 <div class="pf-user">
36 <div class="pf-user-photo"> 40 <div class="pf-user-photo">
37 <img src="<%=basePath %>resource/images/main/user.png" alt=""> 41 <img src="<%=basePath %>resource/images/main/user.png" alt="">
38 </div> 42 </div>
  43 +
39 <h4 class="pf-user-name ellipsis" style="min-width:32px;">${user.loginaccount}</h4> 44 <h4 class="pf-user-name ellipsis" style="min-width:32px;">${user.loginaccount}</h4>
40 <i class="iconfont xiala">&#xe607;</i> 45 <i class="iconfont xiala">&#xe607;</i>
41 46
@@ -251,6 +256,18 @@ @@ -251,6 +256,18 @@
251 window.location.href="<%=basePath %>index?lang="+langVar; 256 window.location.href="<%=basePath %>index?lang="+langVar;
252 } 257 }
253 258
  259 + //重置密码
  260 + function changepassword(id) {
  261 + layer.open({
  262 + type : 2,
  263 + title : '重置密码',
  264 + maxmin : true,
  265 + shadeClose : false, // 点击遮罩关闭层
  266 + area : [ '700px', '350px' ],
  267 + content : '<%=basePath %>system/user/commonPassword?id='+id
  268 + });
  269 + }
  270 +
254 </script> 271 </script>
255 </body> 272 </body>
256 </html> 273 </html>
@@ -29,7 +29,7 @@ String basePath = request.getScheme()+"://"+request.getServerName()+":"+request. @@ -29,7 +29,7 @@ String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.
29 <div style="margin-top: 10px;"> 29 <div style="margin-top: 10px;">
30 <input class="verifyInputs" style="float: left; width: 191px; height: 26px; line-height: 35px; margin-left: 0px; padding: 5px;" name="verifyInput" id="verifyInput" placeholder="请输入验证码"> 30 <input class="verifyInputs" style="float: left; width: 191px; height: 26px; line-height: 35px; margin-left: 0px; padding: 5px;" name="verifyInput" id="verifyInput" placeholder="请输入验证码">
31 31
32 - <img class="verifyCodes" style="float: left; width: 202px; height: 37px; line-height: 35px; margin-left: 11px; padding: 5px; margin-top: -5px;" onclick="changeCode()" src="getVerifyCode"> 32 + <img class="verifyCodes" style="float: left; width: 202px; height: 37px; line-height: 35px; margin-left: 11px; padding: 5px; margin-top: -5px;" onclick="changeCode()" src="/agent/getVerifyCode">
33 33
34 </div> 34 </div>
35 35
@@ -152,7 +152,7 @@ String basePath = request.getScheme()+"://"+request.getServerName()+":"+request. @@ -152,7 +152,7 @@ String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.
152 152
153 function changeCode() { 153 function changeCode() {
154 154
155 - var src = " getVerifyCode?"+new Date().getTime(); //加时间戳,防止浏览器利用缓存 155 + var src = "getVerifyCode?"+new Date().getTime(); //加时间戳,防止浏览器利用缓存
156 156
157 $('.verifyCodes').attr("src",src); 157 $('.verifyCodes').attr("src",src);
158 } 158 }
@@ -261,8 +261,8 @@ @@ -261,8 +261,8 @@
261 if (re.test(passwords)){ 261 if (re.test(passwords)){
262 262
263 $.get("<%=basePath %>system/user/verifyPassword",{id:id, originalpassword:originalpassword},function(data){ 263 $.get("<%=basePath %>system/user/verifyPassword",{id:id, originalpassword:originalpassword},function(data){
264 - if(data.status==500){  
265 - layer.open({content:"<spring:message code="user.differpwd"/>"}); 264 + if(data.status==501){
  265 + layer.open({content:"原密码错误"});
266 return; 266 return;
267 }else if(data.status==200){ 267 }else if(data.status==200){
268 $.post("<%=basePath %>system/user/savepassword",{id:id, originalpassword:originalpassword,newpassword:newpassword,confirmnewpassword:confirmnewpassword},function(data){ 268 $.post("<%=basePath %>system/user/savepassword",{id:id, originalpassword:originalpassword,newpassword:newpassword,confirmnewpassword:confirmnewpassword},function(data){
  1 +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
  2 +<%--
  3 + Created by IntelliJ IDEA.
  4 + User: lenovo
  5 + Date: 2019/3/15
  6 + Time: 16:24
  7 + To change this template use File | Settings | File Templates.
  8 +--%>
  9 +<%@ page contentType="text/html;charset=UTF-8" language="java" %>
  10 +<%
  11 + String path = request.getContextPath();
  12 + String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
  13 +%>
  14 +<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
  15 +<html>
  16 +<head>
  17 + <title>Title</title>
  18 + <meta charset="utf-8">
  19 + <meta name="viewport" content="width=device-width, initial-scale=1">
  20 + <link href="<%=basePath %>resource/css/base.css" rel="stylesheet">
  21 + <link href="<%=basePath %>resource/css/basic_info.css" rel="stylesheet">
  22 + <link rel="stylesheet" href="<%=basePath %>resource/easyui/uimaker/easyui.css">
  23 + <link href="<%=basePath %>resource/css/form.css" rel="stylesheet">
  24 + <link rel="stylesheet" href="<%=basePath %>resource/css/form.css">
  25 + <script type="text/javascript" src="<%=basePath %>resource/easyui/jquery.min.js"></script>
  26 + <script type="text/javascript" src="<%=basePath %>resource/validate/jquery.validate.js"></script>
  27 + <script type="text/javascript" src="<%=basePath %>resource/validate/validate-extends.js"></script>
  28 +
  29 + <script type="text/javascript" src="<%=basePath %>resource/js/tools.js"></script>
  30 + <!-- validate 验证中英文 -->
  31 + <script type="text/javascript" src="<%=basePath %>resource/validate/jquery.validate-${pageContext.response.locale}.js"></script>
  32 +</head>
  33 +<body>
  34 +<div class="container">
  35 + <div class="content">
  36 + <div id="pf-page">
  37 + <div class="easyui-tabs1" style="width:100%;height:100%;">
  38 + <div title="<spring:message code="user.modifypwd"/>" data-options="closable:true">
  39 + <div class="content">
  40 + <form class="from-control" id="form">
  41 + <table class="kv-table">
  42 + <tbody>
  43 + <tr>
  44 + <input type="hidden" id="id" name="id" value="${userid}">
  45 + <td class="kv-label"><spring:message code="user.oldpwd"/></td>
  46 + <td class="kv-content">
  47 + <input type="password" id="originalpassword" name="originalpassword" required maxlength="30">
  48 + </td>
  49 + </tr>
  50 + <tr>
  51 + <td class="kv-label"><spring:message code="user.newpwd"/></td>
  52 + <td class="kv-content"><input type="password" name="newpassword" id="newpassword" onblur="regularValue()" required maxlength="30"><span id="showStrength"></span>
  53 + </td>
  54 + </tr>
  55 + <tr>
  56 + <td class="kv-label"><spring:message code="user.conpwd"/></td>
  57 + <td class="kv-content"><input type="password" name="confirmnewpassword" id="confirmnewpassword" required maxlength="30">
  58 + </td>
  59 + </tr>
  60 + <tr>
  61 + <td colspan="6">
  62 + <div class="opt-buttons" style="padding-top:20px;">
  63 + <button type="submit" href="javascript:doSave()" class="easyui-linkbutton l-btn l-btn-small l-btn-selected " data-options="selected:true">
  64 + <span class="l-btn-left"><span class="l-btn-text"><spring:message code="opt.save"/></span></span>
  65 + </button>
  66 + </div>
  67 + </td>
  68 + </tr>
  69 + </tbody>
  70 + </table>
  71 + </form>
  72 + </div>
  73 + </div>
  74 + </div>
  75 + </div>
  76 + </div>
  77 +</div>
  78 +<%--<script src="http://res.layui.com/lay/lib/layer/src/layer.js?v=2.0"></script>--%>
  79 +<script src="<%=basePath %>resource/easyui/jquery.easyui.min.js"></script>
  80 +
  81 +<script type="text/javascript">
  82 +
  83 + $(function(){
  84 + $("#form").validate({
  85 + rules:{
  86 + confirmnewpassword : {
  87 + equalTo : "#newpassword"
  88 + }
  89 + },
  90 + messages:{
  91 + confirmnewpassword : "<spring:message code="opt.inputpwdagain"/>"
  92 + },
  93 + submitHandler:function(form){
  94 + doSave();
  95 + }
  96 + });
  97 + });
  98 +
  99 +
  100 + function doSave(){
  101 + var originalpassword = $("#originalpassword").val();
  102 + var newpassword = $("#newpassword").val();
  103 + var confirmnewpassword = $("#confirmnewpassword").val();
  104 + var id = $("#id").val();
  105 +
  106 + UPSCGOSCS123
  107 + var passwords = $("#newpassword").val();
  108 +
  109 + var reg = /^(?![A-Za-z0-9]+$)(?![a-z0-9\W]+$)(?![A-Za-z\W]+$)(?![A-Z0-9\W]+$)[a-zA-Z0-9\W]{8,}$/;
  110 +
  111 + var re = new RegExp(reg);
  112 +
  113 + if (re.test(passwords)){
  114 +
  115 + $.get("<%=basePath %>system/user/verifyPassword",{id:id, originalpassword:originalpassword},function(data){
  116 + if(data.status==501){
  117 + alert("原密码错误")
  118 + return;
  119 + }else if(data.status==200){
  120 + $.post("<%=basePath %>system/user/savepassword",{id:id, originalpassword:originalpassword,newpassword:newpassword,confirmnewpassword:confirmnewpassword},function(data){
  121 + if(data.status==200){
  122 + alert("保存成功")
  123 + var index = parent.layer.getFrameIndex(window.name); // 获取窗口索引
  124 + parent.layer.close(index);
  125 + window.parent.location.reload();
  126 +
  127 + }else if(data.status==501){
  128 + alert("两次密码不一致")
  129 + }else {
  130 + alert("保存失败")
  131 + }
  132 + })
  133 + }
  134 + })
  135 +
  136 + }else {
  137 + //不符合规则  
  138 +
  139 + showStrength.innerHTML = "密码不少于8位,英文大小写、数字、特殊符号等相结合".fontcolor("red");
  140 + document.getElementById("newpassword").className = "icon into";
  141 + return false;
  142 + }
  143 + }
  144 +
  145 +
  146 + function regularValue() {
  147 +
  148 + var passwords = $("#newpassword").val();
  149 +
  150 + var reg = /^(?![A-Za-z0-9]+$)(?![a-z0-9\W]+$)(?![A-Za-z\W]+$)(?![A-Z0-9\W]+$)[a-zA-Z0-9\W]{8,}$/;
  151 +
  152 + var re = new RegExp(reg);
  153 +
  154 + if (re.test(passwords)){
  155 + //符合规则  
  156 + showStrength.innerHTML = "".fontcolor("green");
  157 + document.getElementById("newpassword").className = "icon ticker";
  158 + return true;
  159 + }else {
  160 + //不符合规则  
  161 + showStrength.innerHTML = "密码需要英文大小写数字特殊符号等相结合".fontcolor("red");
  162 + document.getElementById("newpassword").className = "icon into";
  163 + return false;
  164 + }
  165 +
  166 + }
  167 +
  168 +
  169 +</script>
  170 +</body>
  171 +</html>