Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
guns-vip
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
chenjunxiong
guns-vip
Commits
983ece4e
Commit
983ece4e
authored
May 03, 2017
by
fsn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增修改密码功能
parent
921db60d
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
89 additions
and
6 deletions
+89
-6
src/main/java/com/stylefeng/guns/common/exception/BizExceptionEnum.java
+2
-0
src/main/java/com/stylefeng/guns/core/shiro/ShiroKit.java
+6
-6
src/main/java/com/stylefeng/guns/modular/system/controller/UserMgrController.java
+30
-0
src/main/webapp/WEB-INF/view/common/_tab.html
+1
-0
src/main/webapp/WEB-INF/view/system/user/user_chpwd.html
+34
-0
src/main/webapp/static/modular/system/user/user_info.js
+16
-0
No files found.
src/main/java/com/stylefeng/guns/common/exception/BizExceptionEnum.java
View file @
983ece4e
...
@@ -33,6 +33,8 @@ public enum BizExceptionEnum {
...
@@ -33,6 +33,8 @@ public enum BizExceptionEnum {
NO_THIS_USER
(
400
,
"没有此用户"
),
NO_THIS_USER
(
400
,
"没有此用户"
),
USER_NOT_EXISTED
(
400
,
"没有此用户"
),
USER_NOT_EXISTED
(
400
,
"没有此用户"
),
ACCOUNT_FREEZED
(
401
,
"账号被冻结"
),
ACCOUNT_FREEZED
(
401
,
"账号被冻结"
),
OLD_PWD_NOT_RIGHT
(
402
,
"原密码不正确"
),
TWO_PWD_NOT_MATCH
(
405
,
"两次输入密码不一致"
),
/**
/**
* 错误的请求
* 错误的请求
...
...
src/main/java/com/stylefeng/guns/core/shiro/ShiroKit.java
View file @
983ece4e
...
@@ -15,8 +15,6 @@
...
@@ -15,8 +15,6 @@
*/
*/
package
com
.
stylefeng
.
guns
.
core
.
shiro
;
package
com
.
stylefeng
.
guns
.
core
.
shiro
;
import
java.util.Random
;
import
org.apache.shiro.SecurityUtils
;
import
org.apache.shiro.SecurityUtils
;
import
org.apache.shiro.crypto.hash.Md5Hash
;
import
org.apache.shiro.crypto.hash.Md5Hash
;
import
org.apache.shiro.crypto.hash.SimpleHash
;
import
org.apache.shiro.crypto.hash.SimpleHash
;
...
@@ -24,6 +22,8 @@ import org.apache.shiro.session.Session;
...
@@ -24,6 +22,8 @@ import org.apache.shiro.session.Session;
import
org.apache.shiro.subject.Subject
;
import
org.apache.shiro.subject.Subject
;
import
org.apache.shiro.util.ByteSource
;
import
org.apache.shiro.util.ByteSource
;
import
java.util.Random
;
/**
/**
* shiro工具类
* shiro工具类
*
*
...
@@ -36,18 +36,18 @@ public class ShiroKit {
...
@@ -36,18 +36,18 @@ public class ShiroKit {
/**
/**
* 加盐参数
* 加盐参数
*/
*/
final
static
String
hashAlgorithmName
=
"MD5"
;
public
final
static
String
hashAlgorithmName
=
"MD5"
;
/**
/**
* 循环次数
* 循环次数
*/
*/
final
static
int
hashIterations
=
1024
;
public
final
static
int
hashIterations
=
1024
;
/**
/**
* shiro密码加密工具类
* shiro密码加密工具类
*
*
* @param 密码
* @param
credentials
密码
* @param 密码盐
* @param
saltSource
密码盐
* @return
* @return
*/
*/
public
static
String
md5
(
String
credentials
,
String
saltSource
)
{
public
static
String
md5
(
String
credentials
,
String
saltSource
)
{
...
...
src/main/java/com/stylefeng/guns/modular/system/controller/UserMgrController.java
View file @
983ece4e
...
@@ -114,6 +114,36 @@ public class UserMgrController extends BaseController {
...
@@ -114,6 +114,36 @@ public class UserMgrController extends BaseController {
}
}
/**
/**
* 跳转到修改密码界面
*/
@RequestMapping
(
"/user_chpwd"
)
public
String
chPwd
(){
return
PREFIX
+
"user_chpwd.html"
;
}
/**
* 修改当前用户的密码
*/
@RequestMapping
(
"/changePwd"
)
@ResponseBody
public
Object
changePwd
(
@RequestParam
String
oldPwd
,
@RequestParam
String
newPwd
,
@RequestParam
String
rePwd
){
if
(!
newPwd
.
equals
(
rePwd
)){
throw
new
BussinessException
(
BizExceptionEnum
.
TWO_PWD_NOT_MATCH
);
}
Integer
userId
=
ShiroKit
.
getUser
().
getId
();
User
user
=
userMapper
.
selectById
(
userId
);
String
oldMd5
=
ShiroKit
.
md5
(
oldPwd
,
user
.
getSalt
());
if
(
user
.
getPassword
().
equals
(
oldMd5
)){
String
newMd5
=
ShiroKit
.
md5
(
newPwd
,
user
.
getSalt
());
user
.
setPassword
(
newMd5
);
user
.
updateById
();
return
SUCCESS_TIP
;
}
else
{
throw
new
BussinessException
(
BizExceptionEnum
.
OLD_PWD_NOT_RIGHT
);
}
}
/**
* 查询管理员列表
* 查询管理员列表
*/
*/
@RequestMapping
(
"/list"
)
@RequestMapping
(
"/list"
)
...
...
src/main/webapp/WEB-INF/view/common/_tab.html
View file @
983ece4e
...
@@ -14,6 +14,7 @@
...
@@ -14,6 +14,7 @@
</a>
</a>
<ul
class=
"dropdown-menu animated fadeInRight m-t-xs"
>
<ul
class=
"dropdown-menu animated fadeInRight m-t-xs"
>
<li><a
class=
"J_menuItem"
href=
"${ctxPath}/mgr/user_info/${shiro.getUser().id}"
>
个人资料
</a></li>
<li><a
class=
"J_menuItem"
href=
"${ctxPath}/mgr/user_info/${shiro.getUser().id}"
>
个人资料
</a></li>
<li><a
class=
"J_menuItem"
href=
"${ctxPath}/mgr/user_chpwd"
>
修改密码
</a></li>
<li
class=
"divider"
></li>
<li
class=
"divider"
></li>
<li><a
href=
"${ctxPath}/logout"
>
安全退出
</a>
<li><a
href=
"${ctxPath}/logout"
>
安全退出
</a>
</li>
</li>
...
...
src/main/webapp/WEB-INF/view/system/user/user_chpwd.html
0 → 100644
View file @
983ece4e
@layout("/common/_container.html"){
<div
class=
"col-sm-4 col-sm-offset-4"
>
<div
class=
"ibox float-e-margins"
>
<div
class=
"ibox-title"
>
<h5>
修改密码
</h5>
</div>
<div
class=
"ibox-content"
>
<div
class=
"row row-lg"
>
<div
class=
"col-sm-12"
>
<div
class=
"ibox float-e-margins"
>
<div
class=
"ibox-content"
style=
"border:none !important; "
>
<div
class=
"form-horizontal"
>
<div
class=
"row"
>
<div
class=
"col-sm-12"
>
<
#
input
id=
"oldPwd"
name=
"原密码"
underline=
"true"
type=
"password"
/>
<
#
input
id=
"newPwd"
name=
"新密码"
underline=
"true"
type=
"password"
/>
<
#
input
id=
"rePwd"
name=
"新密码验证"
type=
"password"
/>
</div>
</div>
<div
class=
"row btn-group-m-t"
>
<div
class=
"col-sm-10"
>
<
#
button
btnCss=
"info"
name=
"提交"
id=
"ensure"
icon=
"fa-check"
clickFun=
"UserInfoDlg.chPwd()"
/>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<script
src=
"${ctxPath}/static/modular/system/user/user_info.js"
></script>
@}
src/main/webapp/static/modular/system/user/user_info.js
View file @
983ece4e
...
@@ -159,6 +159,22 @@ UserInfoDlg.editSubmit = function() {
...
@@ -159,6 +159,22 @@ UserInfoDlg.editSubmit = function() {
ajax
.
start
();
ajax
.
start
();
};
};
/**
* 修改密码
*/
UserInfoDlg
.
chPwd
=
function
(){
var
ajax
=
new
$ax
(
Feng
.
ctxPath
+
"/mgr/changePwd"
,
function
(
data
){
Feng
.
success
(
"修改成功!"
);
},
function
(
data
){
Feng
.
error
(
"修改失败!"
+
data
.
responseJSON
.
message
+
"!"
);
});
ajax
.
set
(
"oldPwd"
);
ajax
.
set
(
"newPwd"
);
ajax
.
set
(
"rePwd"
);
ajax
.
start
();
};
function
onBodyDown
(
event
)
{
function
onBodyDown
(
event
)
{
if
(
!
(
event
.
target
.
id
==
"menuBtn"
||
event
.
target
.
id
==
"menuContent"
||
$
(
if
(
!
(
event
.
target
.
id
==
"menuBtn"
||
event
.
target
.
id
==
"menuContent"
||
$
(
event
.
target
).
parents
(
"#menuContent"
).
length
>
0
))
{
event
.
target
).
parents
(
"#menuContent"
).
length
>
0
))
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment