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

authentication implemented #1177

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

karaedd
Copy link

@karaedd karaedd commented Feb 14, 2025

No description provided.

import mate.academy.model.User;

public class UserService {
private static final User[] users = new User[] {
new User("bob@i.ua", "1234"),
new User("alice@i.ua", "1234")
new User("alice@i.ua", "1234"),

Choose a reason for hiding this comment

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

Suggested change
new User("alice@i.ua", "1234"),
new User("alice@i.ua", "1234")

Comment on lines +19 to +22
if (user == null) {
return false;
}
return user.getPassword().equals(password);

Choose a reason for hiding this comment

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

Suggested change
if (user == null) {
return false;
}
return user.getPassword().equals(password);
return user != null && user.getPassword().equals(password);

@@ -15,6 +16,6 @@ public class UserService {
* Return <code>null</code> if there is no suitable user
*/
public User findByEmail(String email) {
return null;
return Arrays.stream(users).anyMatch(u -> u.getEmail().equals(email)) ? users[0] : null;

Choose a reason for hiding this comment

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

Do you know how stream works? This topic will describe in the future lessons.

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