source: source/MovieZilla-master/src/main/java/com/example/demo/service/ServiceImpl/AuthServiceImpl.java

Last change on this file was fc7ec52, checked in by darkopopovski <darkopopovski39@…>, 2 years ago

all files

  • Property mode set to 100644
File size: 873 bytes
Line 
1package com.example.demo.service.ServiceImpl;
2
3
4import com.example.demo.exceptions.InvalidArgumentsException;
5import com.example.demo.model.User;
6import com.example.demo.repository.UserRepository;
7import com.example.demo.service.AuthService;
8import org.springframework.stereotype.Service;
9
10import java.util.Optional;
11
12@Service
13public class AuthServiceImpl implements AuthService {
14
15 private final UserRepository userRepository;
16 public AuthServiceImpl(UserRepository userRepository) {
17 this.userRepository = userRepository;
18 }
19
20 @Override
21 public Optional<User> login(String username, String password) {
22 if(username==null || username.isEmpty() || password==null || password.isEmpty())
23 {
24
25 throw new InvalidArgumentsException();
26 }
27 return userRepository.findByUsernameAndPassword(username,password);
28 }
29
30}
Note: See TracBrowser for help on using the repository browser.