source: src/main/java/it/finki/charitable/services/UserService.java@ a64f926

Last change on this file since a64f926 was 3fc9e50, checked in by KostaFortumanov <kfortumanov@…>, 3 years ago

prototip part1

  • Property mode set to 100644
File size: 899 bytes
Line 
1package it.finki.charitable.services;
2
3import it.finki.charitable.entities.AppUser;
4import it.finki.charitable.repository.UserRepository;
5import org.springframework.security.core.userdetails.UserDetailsService;
6import org.springframework.security.core.userdetails.UsernameNotFoundException;
7import org.springframework.stereotype.Service;
8
9@Service
10public class UserService implements UserDetailsService {
11
12 private final UserRepository userRepository;
13
14 public UserService(UserRepository userRepository) {
15 this.userRepository = userRepository;
16 }
17
18 @Override
19 public AppUser loadUserByUsername(String s) throws UsernameNotFoundException {
20 return userRepository.findByEmail(s).orElse(null);
21 }
22
23 public void saveUser(AppUser user) {
24 userRepository.save(user);
25 }
26
27 public void deleteUser(AppUser user) {
28 userRepository.delete(user);
29 }
30}
Note: See TracBrowser for help on using the repository browser.