Skip to content
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

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

dudumargato
Copy link

…getUsePassword getters

Comment on lines 25 to 33

public static String getUserEmail(int id) {
return users[id].getEmail();
}

public static String getUserPassword(int id) {
return users[id].getPassword();
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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++) {

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

@@ -11,6 +11,12 @@ public class AuthenticationService {
* Return false in any other cases.
*/
public boolean login(String email, String password) {
UserService user = new UserService();

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

Suggested change
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) {

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.
Comment on lines 18 to 21
User foundUser = userService.findByEmail(email);
return foundUser != null
&& foundUser.getEmail().equals(email)
&& foundUser.getPassword().equals(password);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants