-
Notifications
You must be signed in to change notification settings - Fork 931
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
jv-oop-lesson-0 #1116
base: master
Are you sure you want to change the base?
jv-oop-lesson-0 #1116
Conversation
public boolean equals(Object o) { | ||
if (this == o) { | ||
return true; | ||
} | ||
if (o == null || getClass() != o.getClass()) { | ||
return false; | ||
} | ||
User user = (User) o; | ||
return Objects.equals(email, user.email) | ||
&& Objects.equals(password, user.password); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(email, password); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not needed here
if (userService.findByEmail(email) != null) { | ||
return userService.findByEmail(email).getPassword().equals(password); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't search twice, save result of the search to a local variable
@@ -11,6 +11,10 @@ public class AuthenticationService { | |||
* Return false in any other cases. | |||
*/ | |||
public boolean login(String email, String password) { | |||
UserService userService = new UserService(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
create it on a class level, not a method level
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, left minor comments
public boolean login(String email, String password) { | ||
User user = userService.findByEmail(email); // Save the result to a variable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
User user = userService.findByEmail(email); // Save the result to a variable | |
User user = userService.findByEmail(email); |
@@ -16,4 +16,5 @@ public String getEmail() { | |||
public String getPassword() { | |||
return password; | |||
} | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No description provided.