-
Notifications
You must be signed in to change notification settings - Fork 903
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
implement login and findByEmail methods #1081
base: master
Are you sure you want to change the base?
Conversation
@@ -11,6 +13,11 @@ public class AuthenticationService { | |||
* Return false in any other cases. | |||
*/ | |||
public boolean login(String email, String password) { | |||
User user = new User(email, password); | |||
if (new UserService().findByEmail(email) != 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.
UserService should be a private class-level field, not an anonymous instance
if (new UserService().findByEmail(email) != null | ||
&& user.getPassword().equals(new UserService().findByEmail(email).getPassword())) { |
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.
moreover, you create it twice per each method call. You should create one per each method instance
return true; | ||
} | ||
return 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.
try to rewrite your solution without using true/false boolean literals 😉
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.
almost done
public boolean login(String email, String password) { | ||
return false; | ||
User user = new User(email, 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.
User user = new User(email, password); |
use values directly
public boolean login(String email, String password) { | ||
return false; | ||
User user = new User(email, password); | ||
User checkuser = userService.findByEmail(email); |
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.
User checkuser = userService.findByEmail(email); | |
User user= userService.findByEmail(email); |
No description provided.