use of com.laurentiuspilca.ssc6.entities.User in project tapestry-5 by apache.
the class PersistAll method onCreateUser.
@CommitAfter
void onCreateUser() {
final User user = new User();
user.setFirstName("Foo User");
entityManager.persist(user);
this.user = user;
}
use of com.laurentiuspilca.ssc6.entities.User in project youtubechannel by lspil.
the class JpaUserDetailsService method loadUserByUsername.
@Override
public UserDetails loadUserByUsername(String username) {
var o = userRepository.findUserByUsername(username);
User u = o.orElseThrow(() -> new UsernameNotFoundException(":("));
return new SecurityUser(u);
}
use of com.laurentiuspilca.ssc6.entities.User in project youtubechannel by lspil.
the class UsernamePasswordAuthProvider method authenticate.
@Override
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
String username = authentication.getName();
String password = (String) authentication.getCredentials();
UserDetails user = userDetailsService.loadUserByUsername(username);
if (passwordEncoder.matches(password, user.getPassword())) {
return new UsernamePasswordAuthentication(username, password, user.getAuthorities());
}
throw new BadCredentialsException(":(");
}
use of com.laurentiuspilca.ssc6.entities.User in project youtubechannel by lspil.
the class JPAUserDetailsService method loadUserByUsername.
@Override
public UserDetails loadUserByUsername(String username) {
Optional<User> user = userRepository.findUserByUsername(username);
User u = user.orElseThrow(() -> new UsernameNotFoundException("Error!"));
return new SecurityUser(u);
}
use of com.laurentiuspilca.ssc6.entities.User in project 2021-msk-food-delivery by netcracker-edu.
the class UserDetailsServiceImpl method loadUserByUsername.
// TODO: add courier repo for finding user by phoneNumber
@Override
public UserDetails loadUserByUsername(String login) throws UsernameNotFoundException {
User user = userRepo.findByEmail(login);
// if user not found by Email try find client/courier by phoneNumber
if (user == null) {
Client client = clientRepo.findByPhoneNumber(login);
if (client == null) {
throw new NotFoundEx(login);
}
user = client.getUser();
}
return user;
}
Aggregations