Skip to content
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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

jv-oop-lesson-0 #1116

wants to merge 3 commits into from

Conversation

Nebn1x
Copy link

@Nebn1x Nebn1x commented Oct 8, 2024

No description provided.

Comment on lines 23 to 38
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);
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not needed here

Comment on lines 15 to 17
if (userService.findByEmail(email) != null) {
return userService.findByEmail(email).getPassword().equals(password);
}
Copy link

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();
Copy link

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

@Nebn1x Nebn1x requested a review from okuzan October 8, 2024 19:27
Copy link

@ahoienko ahoienko left a 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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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;
}

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

@Nebn1x Nebn1x requested a review from ahoienko October 9, 2024 20:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants