-
Notifications
You must be signed in to change notification settings - Fork 936
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
login and findByEmail #1150
base: master
Are you sure you want to change the base?
login and findByEmail #1150
Conversation
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.
Please, check build before sending the PR
Let's fix it
public static User[] getUsers() { | ||
return users; | ||
} | ||
|
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.
public static User[] getUsers() { | |
return users; | |
} |
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.
I see, I didn't think about iteraction btwn findByEmail and login
public boolean login(String email, String password) { | ||
for(User user : UserService.getUsers()){ |
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 UserService as class-level variable
don't need to use for loop here
public boolean login(String email, String password) { | ||
for(User user : UserService.getUsers()){ | ||
if(user.getEmail().equals(email) && 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.
you can use ternary operator here
public boolean login(String email, String password) { | ||
return false; | ||
User user = service.findByEmail(email); | ||
return user != null && user.getPassword().equals(password) ? true : false; |
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.
return user != null && user.getPassword().equals(password) ? true : false; | |
return user != null && user.getPassword().equals(password); |
No description provided.