Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gic-platform-auth
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
base_platform_enterprise
gic-platform-auth
Commits
747a2c29
Commit
747a2c29
authored
Sep 06, 2019
by
guojuxing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增/编辑管理员添加标志位,用来操作密码
parent
ffdbd151
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
16 deletions
+14
-16
UserController.java
...main/java/com/gic/auth/web/controller/UserController.java
+8
-2
UserPasswordUtils.java
...c/main/java/com/gic/auth/web/utils/UserPasswordUtils.java
+6
-14
No files found.
gic-platform-auth-web/src/main/java/com/gic/auth/web/controller/UserController.java
View file @
747a2c29
...
...
@@ -29,9 +29,15 @@ public class UserController {
@RequestMapping
(
"/save-or-update-user"
)
public
RestResponse
editUser
(
@Validated
({
UserDTO
.
UserQoValid
.
class
})
UserDTO
userDTO
)
{
Integer
operationPassword
=
userDTO
.
getOperPasswordType
();
userDTO
.
setEnterpriseId
(
UserDetailUtils
.
getUserDetail
().
getEnterpriseId
());
String
password
=
UserPasswordUtils
.
validPassword
(
userDTO
.
getPasswordType
(),
userDTO
.
getPassword
(),
userDTO
.
getOperPasswordType
());
userDTO
.
setPassword
(
UserPasswordUtils
.
getEncryptPassword
(
password
));
if
(
operationPassword
!=
null
&&
operationPassword
.
intValue
()
==
1
)
{
//如果是1,则不用验证密码
}
else
{
String
password
=
UserPasswordUtils
.
validPassword
(
userDTO
.
getPasswordType
(),
userDTO
.
getPassword
());
userDTO
.
setPassword
(
UserPasswordUtils
.
getEncryptPassword
(
password
));
}
ServiceResponse
userResult
;
//普通用户
userDTO
.
setSuperAdmin
(
0
);
...
...
gic-platform-auth-web/src/main/java/com/gic/auth/web/utils/UserPasswordUtils.java
View file @
747a2c29
...
...
@@ -3,9 +3,9 @@ package com.gic.auth.web.utils;
import
org.apache.commons.lang3.StringUtils
;
import
com.gic.auth.constant.UserConstants
;
import
com.gic.auth.exception.AuthException
;
import
com.gic.commons.util.Md5Util
;
import
com.gic.enterprise.error.ErrorCode
;
import
com.gic.enterprise.exception.CommonException
;
import
com.gic.enterprise.utils.CreateRandomUtils
;
/**
* 用户密码生成
...
...
@@ -45,25 +45,17 @@ public class UserPasswordUtils {
* @param password
* @return
*/
public
static
String
validPassword
(
int
passwordType
,
String
password
,
Integer
operPasswordType
)
{
public
static
String
validPassword
(
int
passwordType
,
String
password
)
{
//加密
if
(
UserConstants
.
CREATE_AUTO
==
passwordType
)
{
//自动随机生成
return
createPasswordAuto
(
8
);
}
else
{
if
(
operPasswordType
==
null
)
{
operPasswordType
=
2
;
if
(
StringUtils
.
isNotBlank
(
password
))
{
return
password
;
}
else
{
throw
new
AuthException
(
ErrorCode
.
PARAMETER_ERROR
.
getCode
(),
"密码不能为空"
);
}
if
(
operPasswordType
.
intValue
()
!=
1
)
{
//如果不等于1,则需要验证密码
if
(
StringUtils
.
isNotBlank
(
password
))
{
return
password
;
}
else
{
throw
new
CommonException
(
ErrorCode
.
PARAMETER_ERROR
.
getCode
(),
"密码不能为空"
);
}
}
//如果是1,则不需要密码
return
null
;
}
}
}
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