From 81d1ba58cc5f99c484a10d064707a8c16da1965f Mon Sep 17 00:00:00 2001 From: DmitryShmerchuk Date: Sun, 17 Nov 2024 16:34:25 +0200 Subject: [PATCH] fixed-3 --- .../academy/service/AuthenticationService.java | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/main/java/mate/academy/service/AuthenticationService.java b/src/main/java/mate/academy/service/AuthenticationService.java index a498c0d6e..529685a66 100644 --- a/src/main/java/mate/academy/service/AuthenticationService.java +++ b/src/main/java/mate/academy/service/AuthenticationService.java @@ -3,17 +3,15 @@ import mate.academy.model.User; public class AuthenticationService { - /** - * Imagine that some user wants to login to your site. - * You should check if user credentials (login and password) are valid or not. - * All users are stored in UserService class. - * @param email - user's email - * @param password - user's password - * @return true if user by email exists and passed password is equal to user's password. - * Return false in any other cases. - */ + + private final UserService userService; + + public AuthenticationService() { + this.userService = new UserService(); + } + public boolean login(String email, String password) { - User user = new UserService().findByEmail(email); + User user = userService.findByEmail(email); if (user == null) { return false; }