source: src/main/java/com/example/eatys_app/service/AuthServiceImpl.java@ b3f2adb

Last change on this file since b3f2adb 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 
1package com.example.eatys_app.service;
2
3
4import com.example.eatys_app.model.Korisnik;
5import com.example.eatys_app.model.exceptions.InvalidArgumentsException;
6import com.example.eatys_app.model.exceptions.InvalidUserCredentialsException;
7import com.example.eatys_app.repository.KorisnikRepository;
8import org.springframework.stereotype.Service;
9
10@Service
11public 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.