diff --git a/src/main/java/mate/academy/service/AuthenticationService.java b/src/main/java/mate/academy/service/AuthenticationService.java index aef6b452b..4199bea67 100644 --- a/src/main/java/mate/academy/service/AuthenticationService.java +++ b/src/main/java/mate/academy/service/AuthenticationService.java @@ -12,8 +12,8 @@ public class AuthenticationService { * @return true if user by email exists and passed password is equal to user's password. * Return false in any other cases. */ + private UserService userService = new UserService(); public boolean login(String email, String password) { - UserService userService = new UserService(); User user = userService.findByEmail(email); if (user != null) { if (user.getPassword().equals(password)) { diff --git a/src/main/java/mate/academy/service/UserService.java b/src/main/java/mate/academy/service/UserService.java index 958835626..5d1d79037 100644 --- a/src/main/java/mate/academy/service/UserService.java +++ b/src/main/java/mate/academy/service/UserService.java @@ -15,8 +15,7 @@ public class UserService { * Return null if there is no suitable user */ public User findByEmail(String email) { - for (User user:users - ) { + for (User user:users) { if (user.getEmail().equals(email)) { return user; }