Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
X
xyqb-user2
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
head_group
xyqb-user2
Commits
00317045
Commit
00317045
authored
Aug 01, 2022
by
李健华
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
替换字段名称
parent
f1ad8b38
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
17 additions
and
17 deletions
+17
-17
UserController.java
...n/quantgroup/xyqb/controller/external/UserController.java
+6
-6
InnerController.java
...tgroup/xyqb/controller/internal/user/InnerController.java
+3
-3
PwdVerifyStrategy.java
...yqb/controller/middleoffice/common/PwdVerifyStrategy.java
+3
-3
User.java
src/main/java/cn/quantgroup/xyqb/entity/User.java
+2
-2
UserRegisterServiceImpl.java
...p/xyqb/service/register/impl/UserRegisterServiceImpl.java
+1
-1
UserServiceImpl.java
...cn/quantgroup/xyqb/service/user/impl/UserServiceImpl.java
+2
-2
No files found.
src/main/java/cn/quantgroup/xyqb/controller/external/UserController.java
View file @
00317045
...
@@ -335,7 +335,7 @@ public class UserController implements IBaseController {
...
@@ -335,7 +335,7 @@ public class UserController implements IBaseController {
if
(
user
!=
null
)
{
if
(
user
!=
null
)
{
// 用户注册使用新加密方式
// 用户注册使用新加密方式
// user.setPassword(PasswordUtil.MD5WithSalt(password));
// user.setPassword(PasswordUtil.MD5WithSalt(password));
user
.
set
Encrypted
Password
(
BctyptPasswordUtil
.
BCryptWithSalt
(
password
));
user
.
set
Bcrypt
Password
(
BctyptPasswordUtil
.
BCryptWithSalt
(
password
));
userService
.
saveUser
(
user
);
userService
.
saveUser
(
user
);
log
.
info
(
"用户注册失败,该手机号已经被注册:register -> registerFrom:{}, phoneNo:{}"
,
registerFrom
,
phoneNo
);
log
.
info
(
"用户注册失败,该手机号已经被注册:register -> registerFrom:{}, phoneNo:{}"
,
registerFrom
,
phoneNo
);
//已存在的用户, 经过短信认证, 也认为是注册成功的
//已存在的用户, 经过短信认证, 也认为是注册成功的
...
@@ -457,8 +457,8 @@ public class UserController implements IBaseController {
...
@@ -457,8 +457,8 @@ public class UserController implements IBaseController {
return
JsonResult
.
buildErrorStateResult
(
"修改密码失败"
,
null
);
return
JsonResult
.
buildErrorStateResult
(
"修改密码失败"
,
null
);
}
}
// 优先校验新的密码
// 优先校验新的密码
if
(
StringUtils
.
isNotBlank
(
user
.
get
Encrypted
Password
())
)
{
if
(
StringUtils
.
isNotBlank
(
user
.
get
Bcrypt
Password
())
)
{
if
(!
BctyptPasswordUtil
.
BCryptCheckPw
(
password
,
user
.
get
Encrypted
Password
()))
{
if
(!
BctyptPasswordUtil
.
BCryptCheckPw
(
password
,
user
.
get
Bcrypt
Password
()))
{
return
JsonResult
.
buildErrorStateResult
(
"修改密码失败"
,
null
);
return
JsonResult
.
buildErrorStateResult
(
"修改密码失败"
,
null
);
}
}
}
else
{
}
else
{
...
@@ -752,8 +752,8 @@ public class UserController implements IBaseController {
...
@@ -752,8 +752,8 @@ public class UserController implements IBaseController {
}
}
// 优先校验新密码加密方式 如果有并且密码校验不通过
// 优先校验新密码加密方式 如果有并且密码校验不通过
if
(
StringUtils
.
isNotBlank
(
user
.
get
Encrypted
Password
()))
{
if
(
StringUtils
.
isNotBlank
(
user
.
get
Bcrypt
Password
()))
{
if
(!
BctyptPasswordUtil
.
BCryptCheckPw
(
pass
,
user
.
get
Encrypted
Password
()))
{
if
(!
BctyptPasswordUtil
.
BCryptCheckPw
(
pass
,
user
.
get
Bcrypt
Password
()))
{
// 向该ipv4添加错误计数器
// 向该ipv4添加错误计数器
lockIpv4Service
.
countErrorByIpv4
(
clientIp
);
lockIpv4Service
.
countErrorByIpv4
(
clientIp
);
// 向该phoneNo添加错误计数器
// 向该phoneNo添加错误计数器
...
@@ -770,7 +770,7 @@ public class UserController implements IBaseController {
...
@@ -770,7 +770,7 @@ public class UserController implements IBaseController {
return
null
;
return
null
;
}
}
// 校验老密码正确更新新加密方式
// 校验老密码正确更新新加密方式
user
.
set
Encrypted
Password
(
BctyptPasswordUtil
.
BCryptWithSalt
(
pass
));
user
.
set
Bcrypt
Password
(
BctyptPasswordUtil
.
BCryptWithSalt
(
pass
));
userService
.
saveUser
(
user
);
userService
.
saveUser
(
user
);
}
}
...
...
src/main/java/cn/quantgroup/xyqb/controller/internal/user/InnerController.java
View file @
00317045
...
@@ -1368,8 +1368,8 @@ public class InnerController implements IBaseController {
...
@@ -1368,8 +1368,8 @@ public class InnerController implements IBaseController {
}
}
// 有限校验新密码加密方式
// 有限校验新密码加密方式
if
(
StringUtils
.
isNotBlank
(
user
.
get
Encrypted
Password
()))
{
if
(
StringUtils
.
isNotBlank
(
user
.
get
Bcrypt
Password
()))
{
if
(!
BctyptPasswordUtil
.
BCryptCheckPw
(
password
,
user
.
get
Encrypted
Password
()))
{
if
(!
BctyptPasswordUtil
.
BCryptCheckPw
(
password
,
user
.
get
Bcrypt
Password
()))
{
return
null
;
return
null
;
}
}
}
else
{
}
else
{
...
@@ -1378,7 +1378,7 @@ public class InnerController implements IBaseController {
...
@@ -1378,7 +1378,7 @@ public class InnerController implements IBaseController {
return
null
;
return
null
;
}
}
// 老密码校验后更新新密码加密方式
// 老密码校验后更新新密码加密方式
user
.
set
Encrypted
Password
(
BctyptPasswordUtil
.
BCryptWithSalt
(
password
));
user
.
set
Bcrypt
Password
(
BctyptPasswordUtil
.
BCryptWithSalt
(
password
));
userService
.
saveUser
(
user
);
userService
.
saveUser
(
user
);
}
}
return
user
;
return
user
;
...
...
src/main/java/cn/quantgroup/xyqb/controller/middleoffice/common/PwdVerifyStrategy.java
View file @
00317045
...
@@ -21,9 +21,9 @@ public class PwdVerifyStrategy implements IVerifyStrategy {
...
@@ -21,9 +21,9 @@ public class PwdVerifyStrategy implements IVerifyStrategy {
@Override
@Override
public
void
verify
(
User
user
,
String
verify
)
{
public
void
verify
(
User
user
,
String
verify
)
{
// 如果新加密的密码不为空校验新密码
// 如果新加密的密码不为空校验新密码
String
encryptedPassword
=
user
.
getEncrypted
Password
();
String
bcryptPassword
=
user
.
getBcrypt
Password
();
if
(!
""
.
equals
(
encrypted
Password
))
{
if
(!
""
.
equals
(
bcrypt
Password
))
{
if
(
Objects
.
equals
(
encrypted
Password
,
BctyptPasswordUtil
.
BCryptWithSalt
(
verify
)))
{
if
(
Objects
.
equals
(
bcrypt
Password
,
BctyptPasswordUtil
.
BCryptWithSalt
(
verify
)))
{
return
;
return
;
}
}
throw
new
DataException
(
"用户名或密码错误"
);
throw
new
DataException
(
"用户名或密码错误"
);
...
...
src/main/java/cn/quantgroup/xyqb/entity/User.java
View file @
00317045
...
@@ -45,8 +45,8 @@ public class User extends BaseEntity implements Serializable {
...
@@ -45,8 +45,8 @@ public class User extends BaseEntity implements Serializable {
@Convert
(
converter
=
EncryptConverter
.
class
)
@Convert
(
converter
=
EncryptConverter
.
class
)
private
String
encryptedPhoneNo
;
private
String
encryptedPhoneNo
;
@Column
(
name
=
"
encrypted
_password"
)
@Column
(
name
=
"
bcrypt
_password"
)
private
String
encrypted
Password
;
private
String
bcrypt
Password
;
public
String
getEncryptedPhoneNo
()
{
public
String
getEncryptedPhoneNo
()
{
return
StringUtils
.
isBlank
(
encryptedPhoneNo
)
?
phoneNo
:
encryptedPhoneNo
;
return
StringUtils
.
isBlank
(
encryptedPhoneNo
)
?
phoneNo
:
encryptedPhoneNo
;
...
...
src/main/java/cn/quantgroup/xyqb/service/register/impl/UserRegisterServiceImpl.java
View file @
00317045
...
@@ -161,7 +161,7 @@ public class UserRegisterServiceImpl implements IUserRegisterService {
...
@@ -161,7 +161,7 @@ public class UserRegisterServiceImpl implements IUserRegisterService {
if
(
StringUtils
.
isNotBlank
(
password
))
{
if
(
StringUtils
.
isNotBlank
(
password
))
{
// user.setPassword(PasswordUtil.MD5WithSalt(password));
// user.setPassword(PasswordUtil.MD5WithSalt(password));
// 新建用户使用新加密方式
// 新建用户使用新加密方式
user
.
set
Encrypted
Password
(
BctyptPasswordUtil
.
BCryptWithSalt
(
password
));
user
.
set
Bcrypt
Password
(
BctyptPasswordUtil
.
BCryptWithSalt
(
password
));
}
}
user
=
userService
.
saveUser
(
user
);
user
=
userService
.
saveUser
(
user
);
...
...
src/main/java/cn/quantgroup/xyqb/service/user/impl/UserServiceImpl.java
View file @
00317045
...
@@ -231,10 +231,10 @@ public class UserServiceImpl implements IUserService, IBaseController {
...
@@ -231,10 +231,10 @@ public class UserServiceImpl implements IUserService, IBaseController {
}
}
//修改密码使用新加密方式
//修改密码使用新加密方式
// user.setPassword(PasswordUtil.MD5WithSalt(password));
// user.setPassword(PasswordUtil.MD5WithSalt(password));
user
.
set
Encrypted
Password
(
BctyptPasswordUtil
.
BCryptWithSalt
(
password
));
user
.
set
Bcrypt
Password
(
BctyptPasswordUtil
.
BCryptWithSalt
(
password
));
user
=
userRepository
.
save
(
user
);
user
=
userRepository
.
save
(
user
);
stringRedisTemplate
.
expire
(
"usercache:xyqbuser"
+
phoneNo
,
1L
,
TimeUnit
.
MILLISECONDS
);
stringRedisTemplate
.
expire
(
"usercache:xyqbuser"
+
phoneNo
,
1L
,
TimeUnit
.
MILLISECONDS
);
return
BctyptPasswordUtil
.
BCryptCheckPw
(
password
,
user
.
get
Encrypted
Password
());
return
BctyptPasswordUtil
.
BCryptCheckPw
(
password
,
user
.
get
Bcrypt
Password
());
}
}
@Override
@Override
...
...
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