作者 shenhailong

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

... ... @@ -30,7 +30,7 @@
<commons-lang3.version>3.4</commons-lang3.version>
<commons-fileupload.version>1.3.1</commons-fileupload.version>
<commons-codec.version>1.10</commons-codec.version>
<shiro.version>1.2.3</shiro.version>
<shiro.version>1.4.0</shiro.version>
<cxf.version>2.7.5</cxf.version>
<patchca.version>0.5.0</patchca.version>
<jxl.version>2.6.12</jxl.version>
... ... @@ -330,6 +330,7 @@
<version>${patchca.version}</version>
</dependency>
<!-- oracle jdbc 驱动 -->
<dependency>
<groupId>com.oracle</groupId>
... ... @@ -337,6 +338,7 @@
<version>11.2.0.4.0-atlassian-hosted</version>
</dependency>
<dependency>
<groupId>net.sourceforge.jexcelapi</groupId>
<artifactId>jxl</artifactId>
... ...
... ... @@ -28,7 +28,6 @@ import com.agent.service.system.UserService;
import com.agent.vo.ResponseModel;
import com.agent.vo.agent.UserVo;
import com.framework.core.Servlets;
import com.framework.shiro.SessionUtil;
import com.framework.util.MD5Tools;
import com.plugin.easyui.DataGrid;
import com.plugin.easyui.EasyPage;
... ... @@ -186,6 +185,18 @@ public class UserController extends BasicController {
return "system/user/changepassword";
}
@RequestMapping(value = "/commonPassword")
public String commonPassword(Long id, Model model){
model.addAttribute("userid", id);
return "system/user/commonpassword";
}
/**
* 验证原密码密码
* @return
... ... @@ -201,7 +212,7 @@ public class UserController extends BasicController {
model.setStatus(200);
model.setMsg("验证通过");
}else{
model.setStatus(500);
model.setStatus(501);
model.setMsg("验证失败");
}
} catch (Exception e) {
... ... @@ -228,7 +239,7 @@ public class UserController extends BasicController {
model.setStatus(200);
model.setMsg("修改成功");
}else{
model.setStatus(500);
model.setStatus(501);
model.setMsg("您的两次密码不一致");
}
} catch (Exception e) {
... ...
... ... @@ -16,6 +16,7 @@ import java.awt.image.BufferedImage;
import java.io.IOException;
@RestController
@RequestMapping("/agent")
public class VerifyCodeController extends HttpServlet{
/**
... ...
... ... @@ -32,10 +32,15 @@
</select>
</div>
<div style="height:70px;line-height: 70px;width: 100px;float: right;">
<h4 style="min-width:32px; color: #FFFFFF;"><span onclick="changepassword('${user.id}')">修改密码</span></h4>
</div>
<div class="pf-user">
<div class="pf-user-photo">
<img src="<%=basePath %>resource/images/main/user.png" alt="">
</div>
<h4 class="pf-user-name ellipsis" style="min-width:32px;">${user.loginaccount}</h4>
<i class="iconfont xiala">&#xe607;</i>
... ... @@ -251,6 +256,18 @@
window.location.href="<%=basePath %>index?lang="+langVar;
}
//重置密码
function changepassword(id) {
layer.open({
type : 2,
title : '重置密码',
maxmin : true,
shadeClose : false, // 点击遮罩关闭层
area : [ '700px', '350px' ],
content : '<%=basePath %>system/user/commonPassword?id='+id
});
}
</script>
</body>
</html>
... ...
... ... @@ -29,7 +29,7 @@ String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.
<div style="margin-top: 10px;">
<input class="verifyInputs" style="float: left; width: 191px; height: 26px; line-height: 35px; margin-left: 0px; padding: 5px;" name="verifyInput" id="verifyInput" placeholder="请输入验证码">
<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">
<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">
</div>
... ... @@ -152,7 +152,7 @@ String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.
function changeCode() {
var src = " getVerifyCode?"+new Date().getTime(); //加时间戳,防止浏览器利用缓存
var src = "getVerifyCode?"+new Date().getTime(); //加时间戳,防止浏览器利用缓存
$('.verifyCodes').attr("src",src);
}
... ...
... ... @@ -261,8 +261,8 @@
if (re.test(passwords)){
$.get("<%=basePath %>system/user/verifyPassword",{id:id, originalpassword:originalpassword},function(data){
if(data.status==500){
layer.open({content:"<spring:message code="user.differpwd"/>"});
if(data.status==501){
layer.open({content:"原密码错误"});
return;
}else if(data.status==200){
$.post("<%=basePath %>system/user/savepassword",{id:id, originalpassword:originalpassword,newpassword:newpassword,confirmnewpassword:confirmnewpassword},function(data){
... ...
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
Created by IntelliJ IDEA.
User: lenovo
Date: 2019/3/15
Time: 16:24
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<html>
<head>
<title>Title</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="<%=basePath %>resource/css/base.css" rel="stylesheet">
<link href="<%=basePath %>resource/css/basic_info.css" rel="stylesheet">
<link rel="stylesheet" href="<%=basePath %>resource/easyui/uimaker/easyui.css">
<link href="<%=basePath %>resource/css/form.css" rel="stylesheet">
<link rel="stylesheet" href="<%=basePath %>resource/css/form.css">
<script type="text/javascript" src="<%=basePath %>resource/easyui/jquery.min.js"></script>
<script type="text/javascript" src="<%=basePath %>resource/validate/jquery.validate.js"></script>
<script type="text/javascript" src="<%=basePath %>resource/validate/validate-extends.js"></script>
<script type="text/javascript" src="<%=basePath %>resource/js/tools.js"></script>
<!-- validate 验证中英文 -->
<script type="text/javascript" src="<%=basePath %>resource/validate/jquery.validate-${pageContext.response.locale}.js"></script>
</head>
<body>
<div class="container">
<div class="content">
<div id="pf-page">
<div class="easyui-tabs1" style="width:100%;height:100%;">
<div title="<spring:message code="user.modifypwd"/>" data-options="closable:true">
<div class="content">
<form class="from-control" id="form">
<table class="kv-table">
<tbody>
<tr>
<input type="hidden" id="id" name="id" value="${userid}">
<td class="kv-label"><spring:message code="user.oldpwd"/></td>
<td class="kv-content">
<input type="password" id="originalpassword" name="originalpassword" required maxlength="30">
</td>
</tr>
<tr>
<td class="kv-label"><spring:message code="user.newpwd"/></td>
<td class="kv-content"><input type="password" name="newpassword" id="newpassword" onblur="regularValue()" required maxlength="30"><span id="showStrength"></span>
</td>
</tr>
<tr>
<td class="kv-label"><spring:message code="user.conpwd"/></td>
<td class="kv-content"><input type="password" name="confirmnewpassword" id="confirmnewpassword" required maxlength="30">
</td>
</tr>
<tr>
<td colspan="6">
<div class="opt-buttons" style="padding-top:20px;">
<button type="submit" href="javascript:doSave()" class="easyui-linkbutton l-btn l-btn-small l-btn-selected " data-options="selected:true">
<span class="l-btn-left"><span class="l-btn-text"><spring:message code="opt.save"/></span></span>
</button>
</div>
</td>
</tr>
</tbody>
</table>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
<%--<script src="http://res.layui.com/lay/lib/layer/src/layer.js?v=2.0"></script>--%>
<script src="<%=basePath %>resource/easyui/jquery.easyui.min.js"></script>
<script type="text/javascript">
$(function(){
$("#form").validate({
rules:{
confirmnewpassword : {
equalTo : "#newpassword"
}
},
messages:{
confirmnewpassword : "<spring:message code="opt.inputpwdagain"/>"
},
submitHandler:function(form){
doSave();
}
});
});
function doSave(){
var originalpassword = $("#originalpassword").val();
var newpassword = $("#newpassword").val();
var confirmnewpassword = $("#confirmnewpassword").val();
var id = $("#id").val();
UPSCGOSCS123
var passwords = $("#newpassword").val();
var reg = /^(?![A-Za-z0-9]+$)(?![a-z0-9\W]+$)(?![A-Za-z\W]+$)(?![A-Z0-9\W]+$)[a-zA-Z0-9\W]{8,}$/;
var re = new RegExp(reg);
if (re.test(passwords)){
$.get("<%=basePath %>system/user/verifyPassword",{id:id, originalpassword:originalpassword},function(data){
if(data.status==501){
alert("原密码错误")
return;
}else if(data.status==200){
$.post("<%=basePath %>system/user/savepassword",{id:id, originalpassword:originalpassword,newpassword:newpassword,confirmnewpassword:confirmnewpassword},function(data){
if(data.status==200){
alert("保存成功")
var index = parent.layer.getFrameIndex(window.name); // 获取窗口索引
parent.layer.close(index);
window.parent.location.reload();
}else if(data.status==501){
alert("两次密码不一致")
}else {
alert("保存失败")
}
})
}
})
}else {
//不符合规则  
showStrength.innerHTML = "密码不少于8位,英文大小写、数字、特殊符号等相结合".fontcolor("red");
document.getElementById("newpassword").className = "icon into";
return false;
}
}
function regularValue() {
var passwords = $("#newpassword").val();
var reg = /^(?![A-Za-z0-9]+$)(?![a-z0-9\W]+$)(?![A-Za-z\W]+$)(?![A-Z0-9\W]+$)[a-zA-Z0-9\W]{8,}$/;
var re = new RegExp(reg);
if (re.test(passwords)){
//符合规则  
showStrength.innerHTML = "".fontcolor("green");
document.getElementById("newpassword").className = "icon ticker";
return true;
}else {
//不符合规则  
showStrength.innerHTML = "密码需要英文大小写数字特殊符号等相结合".fontcolor("red");
document.getElementById("newpassword").className = "icon into";
return false;
}
}
</script>
</body>
</html>
... ...