Skip to content

Commit

Permalink
made UserService class level variable, fixed logical mistake
Browse files Browse the repository at this point in the history
  • Loading branch information
Manko Khristi committed Dec 1, 2024
1 parent 7ee556c commit baa2333
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/main/java/mate/academy/service/AuthenticationService.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ 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) {
User user = new UserService().findByEmail(email);
User user = userService.findByEmail(email);
if (user == null) {
return false;
}
return user.getEmail().equals(email) && user.getPassword().equals(password);
return user.getPassword().equals(password);
}
}

0 comments on commit baa2333

Please sign in to comment.