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 | |
---|
1 | package com.example.demo.service.ServiceImpl;
|
---|
2 |
|
---|
3 |
|
---|
4 | import com.example.demo.exceptions.InvalidArgumentsException;
|
---|
5 | import com.example.demo.model.User;
|
---|
6 | import com.example.demo.repository.UserRepository;
|
---|
7 | import com.example.demo.service.AuthService;
|
---|
8 | import org.springframework.stereotype.Service;
|
---|
9 |
|
---|
10 | import java.util.Optional;
|
---|
11 |
|
---|
12 | @Service
|
---|
13 | public 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.