diff --git a/.vs/VSWorkspaceState.json b/.vs/VSWorkspaceState.json new file mode 100644 index 000000000..6b6114114 --- /dev/null +++ b/.vs/VSWorkspaceState.json @@ -0,0 +1,6 @@ +{ + "ExpandedNodes": [ + "" + ], + "PreviewInSolutionExplorer": false +} \ No newline at end of file diff --git a/.vs/jv-oop-lesson-0/v17/.wsuo b/.vs/jv-oop-lesson-0/v17/.wsuo new file mode 100644 index 000000000..2f70d25fa Binary files /dev/null and b/.vs/jv-oop-lesson-0/v17/.wsuo differ diff --git a/.vs/jv-oop-lesson-0/v17/DocumentLayout.json b/.vs/jv-oop-lesson-0/v17/DocumentLayout.json new file mode 100644 index 000000000..a9abaa9cb --- /dev/null +++ b/.vs/jv-oop-lesson-0/v17/DocumentLayout.json @@ -0,0 +1,12 @@ +{ + "Version": 1, + "WorkspaceRootPath": "C:\\Users\\sofyh\\Source\\Repos\\jv-oop-lesson-0\\", + "Documents": [], + "DocumentGroupContainers": [ + { + "Orientation": 0, + "VerticalTabListWidth": 256, + "DocumentGroups": [] + } + ] +} \ No newline at end of file diff --git a/src/main/java/mate/academy/service/AuthenticationService.java b/src/main/java/mate/academy/service/AuthenticationService.java index 8f7c7c975..2d6983b02 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. @@ -10,7 +12,14 @@ 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 UserService getUserService() { + return userService; + } + public boolean login(String email, String password) { - return false; + User user = getUserService().findByEmail(email); + return user != null && 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 1652d7d68..b9701582e 100644 --- a/src/main/java/mate/academy/service/UserService.java +++ b/src/main/java/mate/academy/service/UserService.java @@ -14,7 +14,13 @@ public class UserService { * @return - user if his email is equal to passed email. * 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; } }