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
Eladmin
Commits
d35ffc9d
Commit
d35ffc9d
authored
Apr 23, 2020
by
ZhengJie
Browse files
Merge branch '2.5dev' of
https://github.com/jhpx/eladmin
parents
2380ed79
c4ddacc7
Changes
1
Hide whitespace changes
Inline
Side-by-side
eladmin-system/src/main/java/me/zhengjie/modules/security/service/UserDetailsServiceImpl.java
View file @
d35ffc9d
package
me.zhengjie.modules.security.service
;
package
me.zhengjie.modules.security.service
;
import
me.zhengjie.exception.BadRequestException
;
import
me.zhengjie.exception.BadRequestException
;
import
me.zhengjie.exception.EntityNotFoundException
;
import
me.zhengjie.modules.security.service.dto.JwtUserDto
;
import
me.zhengjie.modules.security.service.dto.JwtUserDto
;
import
me.zhengjie.modules.system.service.RoleService
;
import
me.zhengjie.modules.system.service.RoleService
;
import
me.zhengjie.modules.system.service.UserService
;
import
me.zhengjie.modules.system.service.UserService
;
import
me.zhengjie.modules.system.service.dto.
*
;
import
me.zhengjie.modules.system.service.dto.
UserDto
;
import
org.springframework.security.core.userdetails.UserDetailsService
;
import
org.springframework.security.core.userdetails.UserDetailsService
;
import
org.springframework.security.core.userdetails.UsernameNotFoundException
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
...
@@ -28,10 +30,16 @@ public class UserDetailsServiceImpl implements UserDetailsService {
...
@@ -28,10 +30,16 @@ public class UserDetailsServiceImpl implements UserDetailsService {
}
}
@Override
@Override
public
JwtUserDto
loadUserByUsername
(
String
username
){
public
JwtUserDto
loadUserByUsername
(
String
username
)
{
UserDto
user
=
userService
.
findByName
(
username
);
UserDto
user
;
try
{
user
=
userService
.
findByName
(
username
);
}
catch
(
EntityNotFoundException
e
)
{
// SpringSecurity会自动转换UsernameNotFoundException为BadCredentialsException
throw
new
UsernameNotFoundException
(
""
,
e
);
}
if
(
user
==
null
)
{
if
(
user
==
null
)
{
throw
new
BadRequest
Exception
(
"
账号不存在
"
);
throw
new
UsernameNotFound
Exception
(
""
);
}
else
{
}
else
{
if
(!
user
.
getEnabled
())
{
if
(!
user
.
getEnabled
())
{
throw
new
BadRequestException
(
"账号未激活"
);
throw
new
BadRequestException
(
"账号未激活"
);
...
...
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