-
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
implemented login and findByEmail methods along with getUseEmail and … #1179
base: master
Are you sure you want to change the base?
Conversation
…getUsePassword getters
|
||
public static String getUserEmail(int id) { | ||
return users[id].getEmail(); | ||
} | ||
|
||
public static String getUserPassword(int id) { | ||
return users[id].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.
public static String getUserEmail(int id) { | |
return users[id].getEmail(); | |
} | |
public static String getUserPassword(int id) { | |
return users[id].getPassword(); | |
} |
@@ -11,6 +11,13 @@ public class AuthenticationService { | |||
* Return false in any other cases. | |||
*/ | |||
public boolean login(String email, String password) { | |||
for (int i = 0; i < 2; i++) { |
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.
It's better to create UserService class-level variable
find user by email by using findByEmail()
check password and user not null
Co-authored-by: Olena Bruiako <[email protected]>
…rom UseService method
…son-0 into methods-implement
@@ -11,6 +11,12 @@ public class AuthenticationService { | |||
* Return false in any other cases. | |||
*/ | |||
public boolean login(String email, String password) { | |||
UserService user = new 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.
it should be class-level variable (not method)
in this case - you create userService
object each time you call login
method
Wrong name of variable
UserService user = new UserService(); | |
UserService userService = new UserService(); |
@@ -11,6 +11,12 @@ public class AuthenticationService { | |||
* Return false in any other cases. | |||
*/ | |||
public boolean login(String email, String password) { | |||
UserService user = new UserService(); | |||
if (email != null && password != 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.
create local variable for user, that you find by email and implement HW
…al variable for method. Replaced 'if' method with additional 'return' condition.
User foundUser = userService.findByEmail(email); | ||
return foundUser != null | ||
&& foundUser.getEmail().equals(email) | ||
&& foundUser.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.
User foundUser = userService.findByEmail(email); | |
return foundUser != null | |
&& foundUser.getEmail().equals(email) | |
&& foundUser.getPassword().equals(password); | |
User user = userService.findByEmail(email); | |
return user != null && user.getPassword().equals(password); |
…getUsePassword getters