Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
Litemall
Commits
fb54dd3c
Commit
fb54dd3c
authored
Jul 17, 2018
by
Junling Bu
Browse files
fix[litemall-admin-api]: 修复管理后台用户添加密码未加密
parent
b1be8858
Changes
1
Hide whitespace changes
Inline
Side-by-side
litemall-admin-api/src/main/java/org/linlinjava/litemall/admin/web/AdminUserController.java
View file @
fb54dd3c
...
...
@@ -4,6 +4,8 @@ import com.github.pagehelper.util.StringUtil;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.linlinjava.litemall.admin.annotation.LoginAdmin
;
import
org.linlinjava.litemall.core.util.RegexUtil
;
import
org.linlinjava.litemall.core.util.bcrypt.BCryptPasswordEncoder
;
import
org.linlinjava.litemall.db.domain.LitemallUser
;
import
org.linlinjava.litemall.db.service.LitemallUserService
;
import
org.linlinjava.litemall.core.util.ResponseUtil
;
...
...
@@ -58,6 +60,26 @@ public class AdminUserController {
@PostMapping
(
"/create"
)
public
Object
create
(
@LoginAdmin
Integer
adminId
,
@RequestBody
LitemallUser
user
){
logger
.
debug
(
user
);
String
username
=
user
.
getUsername
();
String
mobile
=
user
.
getMobile
();
List
<
LitemallUser
>
userList
=
userService
.
queryByUsername
(
username
);
if
(
userList
.
size
()
>
0
){
return
ResponseUtil
.
fail
(
403
,
"用户名已注册"
);
}
userList
=
userService
.
queryByMobile
(
mobile
);
if
(
userList
.
size
()
>
0
){
return
ResponseUtil
.
fail
(
403
,
"手机号已注册"
);
}
if
(!
RegexUtil
.
isMobileExact
(
mobile
)){
return
ResponseUtil
.
fail
(
403
,
"手机号格式不正确"
);
}
String
password
=
user
.
getPassword
();
BCryptPasswordEncoder
encoder
=
new
BCryptPasswordEncoder
();
String
encodedPassword
=
encoder
.
encode
(
password
);
user
.
setPassword
(
encodedPassword
);
user
.
setAddTime
(
LocalDateTime
.
now
());
userService
.
add
(
user
);
return
ResponseUtil
.
ok
(
user
);
...
...
Write
Preview
Supports
Markdown
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