diff --git a/src/main/java/mate/academy/service/AuthenticationService.java b/src/main/java/mate/academy/service/AuthenticationService.java index 8f7c7c975..aef6b452b 100644 --- a/src/main/java/mate/academy/service/AuthenticationService.java +++ b/src/main/java/mate/academy/service/AuthenticationService.java @@ -1,5 +1,7 @@ package mate.academy.service; +import mate.academy.model.User; + public class AuthenticationService { /** * Imagine that some user wants to login to your site. @@ -11,6 +13,13 @@ public class AuthenticationService { * Return false in any other cases. */ public boolean login(String email, String password) { + UserService userService = new UserService(); + User user = userService.findByEmail(email); + if (user != null) { + if (user.getPassword().equals(password)) { + return true; + } + } return false; } } diff --git a/src/main/java/mate/academy/service/UserService.java b/src/main/java/mate/academy/service/UserService.java index 1652d7d68..958835626 100644 --- a/src/main/java/mate/academy/service/UserService.java +++ b/src/main/java/mate/academy/service/UserService.java @@ -15,6 +15,12 @@ public class UserService { * Return null if there is no suitable user */ public User findByEmail(String email) { + for (User user:users + ) { + if (user.getEmail().equals(email)) { + return user; + } + } return null; } }