-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
50 additions
and
51 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
backend/src/main/java/club/klabis/config/authserver/ApplicationUserDetailsService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package club.klabis.config.authserver; | ||
|
||
import club.klabis.domain.appusers.ApplicationUser; | ||
import club.klabis.domain.appusers.ApplicationUsersRepository; | ||
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.Component; | ||
|
||
@Component | ||
class ApplicationUserDetailsService implements UserDetailsService { | ||
|
||
private final ApplicationUsersRepository applicationUsersRepository; | ||
|
||
public ApplicationUserDetailsService(ApplicationUsersRepository applicationUsersRepository) { | ||
this.applicationUsersRepository = applicationUsersRepository; | ||
} | ||
|
||
@Override | ||
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { | ||
return applicationUsersRepository.findByUserName(username) | ||
.map(this::fromMember) | ||
.orElseThrow(() -> new UsernameNotFoundException("User with username %s not found".formatted(username))); | ||
} | ||
|
||
private UserDetails fromMember(ApplicationUser member) { | ||
return User.withUsername(member.getUsername()) | ||
.password(member.getPassword()) | ||
.disabled(member.isDisabled()) | ||
.build(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 0 additions & 39 deletions
39
backend/src/main/java/club/klabis/config/authserver/UsersDetailsServiceConfiguration.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters