From fb696c9bb64e44a09f175b276c57a64c9637d02c Mon Sep 17 00:00:00 2001 From: Nikita Date: Thu, 9 May 2024 17:38:12 +0300 Subject: [PATCH] fixed AuthenticationService --- .../mate/academy/service/AuthenticationService.java | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/main/java/mate/academy/service/AuthenticationService.java b/src/main/java/mate/academy/service/AuthenticationService.java index c71991715..d33367df4 100644 --- a/src/main/java/mate/academy/service/AuthenticationService.java +++ b/src/main/java/mate/academy/service/AuthenticationService.java @@ -1,9 +1,7 @@ package mate.academy.service; -import mate.academy.model.User; - public class AuthenticationService { - private static final UserService AUTHENTICATION_SERVICE = new UserService(); + private final UserService userService = new UserService(); /** * Imagine that some user wants to login to your site. * You should check if user credentials (login and password) are valid or not. @@ -17,10 +15,6 @@ public class AuthenticationService { */ public boolean login(String email, String password) { - User userFromDb = AUTHENTICATION_SERVICE.findByEmail(email); - if (userFromDb == null) { - return false; - } - return userFromDb.getPassword().equals(password); + return userService.findByEmail(email).getPassword().equals(password); } }