Last change
on this file was b3f2adb, checked in by Aleksandar Siljanoski <acewow3@…>, 14 months ago |
Adding project to repo
|
-
Property mode
set to
100644
|
File size:
975 bytes
|
Line | |
---|
1 | package com.example.eatys_app.service;
|
---|
2 |
|
---|
3 |
|
---|
4 | import com.example.eatys_app.model.Korisnik;
|
---|
5 | import com.example.eatys_app.model.exceptions.InvalidArgumentsException;
|
---|
6 | import com.example.eatys_app.model.exceptions.InvalidUserCredentialsException;
|
---|
7 | import com.example.eatys_app.repository.KorisnikRepository;
|
---|
8 | import org.springframework.stereotype.Service;
|
---|
9 |
|
---|
10 | @Service
|
---|
11 | public class AuthServiceImpl implements AuthService{
|
---|
12 |
|
---|
13 | private final KorisnikRepository korisnikRepository;
|
---|
14 |
|
---|
15 | public AuthServiceImpl(KorisnikRepository korisnikRepository) {
|
---|
16 | this.korisnikRepository = korisnikRepository;
|
---|
17 | }
|
---|
18 |
|
---|
19 | @Override
|
---|
20 | public Korisnik login(String username, String password) {
|
---|
21 | if (username==null || username.isEmpty() || password==null || password.isEmpty()) {
|
---|
22 | throw new InvalidArgumentsException();
|
---|
23 | }
|
---|
24 | return korisnikRepository.findByImeAndPassword(username,
|
---|
25 | password).orElseThrow(InvalidUserCredentialsException::new);
|
---|
26 | }
|
---|
27 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.