Total Complexity | 3 |
Total Lines | 16 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | package com.osomapps.pt.auth; |
||
11 | @Service("customUserDetailsService") |
||
12 | public class CustomUserDetailsService implements UserDetailsService { |
||
13 | |||
14 | private final PtUserRepository ptUserRepository; |
||
15 | |||
16 | CustomUserDetailsService(PtUserRepository ptUserRepository) { |
||
17 | this.ptUserRepository = ptUserRepository; |
||
18 | } |
||
19 | |||
20 | @Override |
||
21 | public UserDetails loadUserByUsername(String username) { |
||
22 | final List<PtUser> ptUsers = ptUserRepository.findByLogin(username); |
||
23 | if (ptUsers.isEmpty()) { |
||
24 | throw new UsernameNotFoundException("No user present with username: " + username); |
||
25 | } |
||
26 | return new CustomUserDetails(ptUsers.get(ptUsers.size() - 1)); |
||
27 | } |
||
29 |