Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Alba María Álvarez
/
AppRecetas
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
87efc5f6
authored
Jun 19, 2025
by
Alba María Álvarez
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
feat(security): implementado servicio de CustomUserDetailsService
parent
006feb0f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
0 deletions
src/main/java/com/example/apprecetas/security/service/CustomUserDetailsServiceImpl.java
src/main/java/com/example/apprecetas/security/service/CustomUserDetailsServiceImpl.java
0 → 100644
View file @
87efc5f6
package
com
.
example
.
apprecetas
.
security
.
service
;
import
com.example.apprecetas.user.domain.repository.ReadUserRepository
;
import
lombok.RequiredArgsConstructor
;
import
org.springframework.security.core.userdetails.User
;
import
org.springframework.security.core.userdetails.UserDetails
;
import
org.springframework.security.core.userdetails.UserDetailsService
;
import
org.springframework.security.core.userdetails.UsernameNotFoundException
;
import
org.springframework.stereotype.Service
;
@Service
@RequiredArgsConstructor
public
class
CustomUserDetailsServiceImpl
implements
UserDetailsService
{
private
final
ReadUserRepository
userRepository
;
@Override
public
UserDetails
loadUserByUsername
(
String
username
)
throws
UsernameNotFoundException
{
return
userRepository
.
readByUsername
(
username
)
.
map
(
user
->
User
.
withUsername
(
user
.
getUsername
())
.
password
(
user
.
getPassword
())
.
roles
(
user
.
getRole
().
name
())
.
build
())
.
orElseThrow
(()
->
new
UsernameNotFoundException
(
"User con username "
+
username
+
" no encontrado"
));
}
}
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