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
9081d3a2
Commit
9081d3a2
authored
Nov 24, 2017
by
技术部-任文超
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加Log
parent
71ac09e0
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
12 deletions
+26
-12
CaptchaFiniteValidateAdvisor.java
...oup/xyqb/aspect/captcha/CaptchaFiniteValidateAdvisor.java
+1
-0
ExceptionHandlingController.java
...antgroup/xyqb/controller/ExceptionHandlingController.java
+3
-0
UserController.java
...ntgroup/xyqb/controller/internal/user/UserController.java
+22
-12
No files found.
src/main/java/cn/quantgroup/xyqb/aspect/captcha/CaptchaFiniteValidateAdvisor.java
View file @
9081d3a2
...
@@ -89,6 +89,7 @@ public class CaptchaFiniteValidateAdvisor {
...
@@ -89,6 +89,7 @@ public class CaptchaFiniteValidateAdvisor {
String
phoneNo
=
phonePasswordMap
.
get
(
"phoneNo"
);
String
phoneNo
=
phonePasswordMap
.
get
(
"phoneNo"
);
Long
countErrorByPhone
=
getCount
(
phoneNo
);
Long
countErrorByPhone
=
getCount
(
phoneNo
);
if
(
countErrorByPhone
==
null
){
if
(
countErrorByPhone
==
null
){
LOGGER
.
info
(
"用户名或密码不正确, phoneNo={}, countErrorByPhone={}, clientIp={}"
,
phoneNo
,
countErrorByPhone
,
request
.
getRemoteAddr
());
return
JsonResult
.
buildErrorStateResult
(
"用户名或密码不正确"
,
null
);
return
JsonResult
.
buildErrorStateResult
(
"用户名或密码不正确"
,
null
);
}
}
if
(
countErrorByPhone
>
Constants
.
Image_Need_Count
)
{
if
(
countErrorByPhone
>
Constants
.
Image_Need_Count
)
{
...
...
src/main/java/cn/quantgroup/xyqb/controller/ExceptionHandlingController.java
View file @
9081d3a2
...
@@ -42,6 +42,7 @@ public class ExceptionHandlingController implements IBaseController {
...
@@ -42,6 +42,7 @@ public class ExceptionHandlingController implements IBaseController {
*/
*/
@ExceptionHandler
(
PasswordErrorLimitException
.
class
)
@ExceptionHandler
(
PasswordErrorLimitException
.
class
)
public
JsonResult
passwordErrorLimitException
(
PasswordErrorLimitException
vce
)
{
public
JsonResult
passwordErrorLimitException
(
PasswordErrorLimitException
vce
)
{
LOGGER
.
info
(
"throw PasswordErrorLimitException,msg={},businessCode={}"
,
vce
.
getMessage
(),
2L
);
return
JsonResult
.
buildErrorStateResult
(
vce
.
getMessage
(),
null
,
2L
);
return
JsonResult
.
buildErrorStateResult
(
vce
.
getMessage
(),
null
,
2L
);
}
}
...
@@ -53,12 +54,14 @@ public class ExceptionHandlingController implements IBaseController {
...
@@ -53,12 +54,14 @@ public class ExceptionHandlingController implements IBaseController {
*/
*/
@ExceptionHandler
(
VerificationCodeErrorException
.
class
)
@ExceptionHandler
(
VerificationCodeErrorException
.
class
)
public
JsonResult
verificationCodeErrorException
(
VerificationCodeErrorException
vce
)
{
public
JsonResult
verificationCodeErrorException
(
VerificationCodeErrorException
vce
)
{
LOGGER
.
info
(
"throw VerificationCodeErrorException,msg={},businessCode={}"
,
vce
.
getMessage
(),
1L
);
return
JsonResult
.
buildErrorStateResult
(
vce
.
getMessage
(),
null
,
1L
);
return
JsonResult
.
buildErrorStateResult
(
vce
.
getMessage
(),
null
,
1L
);
}
}
@ExceptionHandler
(
UserNotExistException
.
class
)
@ExceptionHandler
(
UserNotExistException
.
class
)
@ResponseStatus
(
HttpStatus
.
UNAUTHORIZED
)
@ResponseStatus
(
HttpStatus
.
UNAUTHORIZED
)
public
JsonResult
userNotExistException
(
UserNotExistException
unee
)
{
public
JsonResult
userNotExistException
(
UserNotExistException
unee
)
{
LOGGER
.
info
(
"throw UserNotExistException,msg={},businessCode={},code={}"
,
unee
.
getMessage
(),
1L
,
401L
);
return
new
JsonResult
(
unee
.
getMessage
(),
401L
,
null
);
return
new
JsonResult
(
unee
.
getMessage
(),
401L
,
null
);
}
}
...
...
src/main/java/cn/quantgroup/xyqb/controller/internal/user/UserController.java
View file @
9081d3a2
...
@@ -531,8 +531,10 @@ public class UserController implements IBaseController {
...
@@ -531,8 +531,10 @@ public class UserController implements IBaseController {
}
}
String
[]
credentialArr
=
bufStr
.
split
(
":"
);
String
[]
credentialArr
=
bufStr
.
split
(
":"
);
if
(
credentialArr
.
length
!=
2
)
{
if
(
credentialArr
.
length
!=
2
)
{
LOGGER
.
info
(
"用户登录失败:{}"
,
bufStr
);
return
null
;
return
null
;
}
}
LOGGER
.
info
(
"用户正在登录... [{}]"
,
credentialArr
);
String
userName
=
credentialArr
[
0
];
String
userName
=
credentialArr
[
0
];
String
pass
=
credentialArr
[
1
];
String
pass
=
credentialArr
[
1
];
User
user
=
userService
.
findByPhoneWithCache
(
userName
);
User
user
=
userService
.
findByPhoneWithCache
(
userName
);
...
@@ -541,8 +543,19 @@ public class UserController implements IBaseController {
...
@@ -541,8 +543,19 @@ public class UserController implements IBaseController {
}
}
//验证密码
//验证密码
if
(!
validatePassword
(
pass
,
user
.
getPassword
()))
{
if
(!
validatePassword
(
pass
,
user
.
getPassword
()))
{
doErrorCount
(
userName
);
return
null
;
}
return
user
;
}
/**
* 执行账密登录错误计数
* @param phoneNo
*/
private
void
doErrorCount
(
String
phoneNo
)
{
// 密码错误时,给该账号添加计数器
// 密码错误时,给该账号添加计数器
String
key
=
Constants
.
REDIS_PASSWORD_ERROR_COUNT
+
userName
;
String
key
=
Constants
.
REDIS_PASSWORD_ERROR_COUNT
+
phoneNo
;
if
(!
stringRedisTemplate
.
hasKey
(
key
))
{
if
(!
stringRedisTemplate
.
hasKey
(
key
))
{
stringRedisTemplate
.
opsForValue
().
set
(
key
,
String
.
valueOf
(
0
),
DateUtils
.
getSeconds
(),
TimeUnit
.
SECONDS
);
stringRedisTemplate
.
opsForValue
().
set
(
key
,
String
.
valueOf
(
0
),
DateUtils
.
getSeconds
(),
TimeUnit
.
SECONDS
);
}
}
...
@@ -553,9 +566,6 @@ public class UserController implements IBaseController {
...
@@ -553,9 +566,6 @@ public class UserController implements IBaseController {
}
else
if
(
Objects
.
equals
(
errorCount
,
Constants
.
Image_Need_Count
)){
}
else
if
(
Objects
.
equals
(
errorCount
,
Constants
.
Image_Need_Count
)){
throw
new
PasswordErrorLimitException
(
"请输入图形验证码"
);
throw
new
PasswordErrorLimitException
(
"请输入图形验证码"
);
}
}
return
null
;
}
return
user
;
}
}
private
boolean
validatePassword
(
String
paramPass
,
String
targetPassword
)
{
private
boolean
validatePassword
(
String
paramPass
,
String
targetPassword
)
{
...
...
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