source: Prototype Application/Paw5/src/main/java/finki/paw5/service/implementation/AuthServiceImpl.java@ f0232fb

main
Last change on this file since f0232fb was f0232fb, checked in by trajchevaM <118018439+trajchevaM@…>, 17 months ago

login and home

  • Property mode set to 100644
File size: 1.5 KB
Line 
1package finki.paw5.service.implementation;
2
3import finki.paw5.model.entities.User;
4import finki.paw5.model.exceptions.NonExistingArgumentsException;
5import finki.paw5.repository.UserRepository;
6import finki.paw5.service.AuthService;
7import org.springframework.stereotype.Service;
8
9import java.time.LocalDate;
10import java.util.Objects;
11import java.util.Optional;
12
13@Service
14public class AuthServiceImpl implements AuthService {
15
16 private final UserRepository userRepository;
17
18 public AuthServiceImpl(UserRepository userRepository) {
19 this.userRepository = userRepository;
20 }
21
22 @Override
23 public User login(String email, String password) {
24
25 if(userRepository.findByEmailAndPassword(email, password)!=null){
26 return userRepository.findByEmailAndPassword(email,password);
27 }
28 return null;
29 }
30
31 /*
32 @Override
33 public Adopter registerAdopter(String password, String repeatPassword, String name, String email, String telephone) {
34 if (email == null || email.isEmpty() || password == null || password.isEmpty()) {
35 //throw new Exception();
36 }
37 if (!password.equals(repeatPassword)) {
38 //throw new Exception();
39 }
40 if (this.userRepository.findByEmail(email)!=null) {
41 //throw new Exception("Username exists:"+email);
42 }
43 User user = new User(LocalDate.now(), name, email, password, telephone);
44 return userRepository.save(user);
45 }
46 */
47}
Note: See TracBrowser for help on using the repository browser.