-
Notifications
You must be signed in to change notification settings - Fork 946
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
base: master
Are you sure you want to change the base?
Conversation
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"), |
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.
new User("alice@i.ua", "1234"), | |
new User("alice@i.ua", "1234") |
if (user == null) { | ||
return false; | ||
} | ||
return user.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.
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; |
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.
Do you know how stream works? This topic will describe in the future lessons.
No description provided.