-
Notifications
You must be signed in to change notification settings - Fork 948
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
Implementation of methods login and findByEmail #914
base: master
Are you sure you want to change the base?
Implementation of methods login and findByEmail #914
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.
Good job overall
@@ -11,6 +13,11 @@ public class AuthenticationService { | |||
* Return false in any other cases. | |||
*/ | |||
public boolean login(String email, String password) { | |||
User user = new 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.
UserService
must be a class field
User user = new UserService().findByEmail(email); | |
User user = userService.findByEmail(email); |
public class AuthenticationService { | ||
private UserService userService; |
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.
- field is not initialized
- make it
final
if (user != null) { | ||
return user.getPassword().equals(password); | ||
} | ||
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.
good code is simple code. think about how to make it inline
if (user != null && user.getPassword().equals(password)) { | ||
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.
rewrite it in one line
return false; | ||
User user = userService.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.
really not bad try, but... seriously?))
return (user != null && user.getPassword().equals(password)) ? true : false; | |
return user != null && user.getPassword().equals(password)); |
No description provided.