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

added authentication service #1007

Closed

Conversation

kriazantseva
Copy link

No description provided.

@kriazantseva
Copy link
Author

everything fine?

return false;
}

Choose a reason for hiding this comment

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

Suggested change

@@ -15,6 +15,12 @@ public class UserService {
* Return <code>null</code> if there is no suitable user
*/
public User findByEmail(String email) {

Choose a reason for hiding this comment

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

Suggested change

Comment on lines +19 to +23
for (int i = 0; i < users.length; i++) {
if (users[i].getEmail().equals(email)) {
return users[i];
}
}

Choose a reason for hiding this comment

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

You can do like Map userEmailToPassword, to avoid O(n)

Copy link
Author

Choose a reason for hiding this comment

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

I am confident that using a map can effectively optimize the code and speed up its compilation. However, I have not yet studied this in this course, so I cannot apply it. Most likely, this will be explained in the next topics, so do not consider my solution incorrect. I have removed the unnecessary lines you pointed out, as can be seen in the following commit

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.

2 participants