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

write in AuthenticationService - login method and in class UserServic… #908

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

Conversation

AnMishkin
Copy link

…e - findByEmail method

return false;
boolean existUser;

UserService users = new UserService();

Choose a reason for hiding this comment

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

move to the class field

Comment on lines 19 to 20
User equalsUser;
equalsUser = users.findByEmail(email);

Choose a reason for hiding this comment

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

Suggested change
User equalsUser;
equalsUser = users.findByEmail(email);
User user = users.findByEmail(email);

return false;
boolean existUser;

UserService users = new UserService();

Choose a reason for hiding this comment

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

Suggested change
UserService users = new UserService();
UserService userService = new UserService();

@@ -11,6 +13,18 @@ public class AuthenticationService {
* Return false in any other cases.
*/
public boolean login(String email, String password) {
return false;
boolean existUser;

Choose a reason for hiding this comment

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

Suggested change
boolean existUser;

Copy link
Author

Choose a reason for hiding this comment

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

in this recommendation,i understand what you mean

User equalsUser;
equalsUser = users.findByEmail(email);

if (equalsUser.getPassword() == password) {

Choose a reason for hiding this comment

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

how we need equal string? :)

Comment on lines 22 to 28
if (equalsUser.getPassword() == password) {
existUser = true;
} else {
existUser = false;
}

return existUser;

Choose a reason for hiding this comment

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

Suggested change
if (equalsUser.getPassword() == password) {
existUser = true;
} else {
existUser = false;
}
return existUser;
return user != null && user.getPassword().equals(password);

@@ -11,6 +16,9 @@ public class AuthenticationService {
* Return false in any other cases.
*/
public boolean login(String email, String password) {
return false;
UserService usersService = new UserService();
Copy link

Choose a reason for hiding this comment

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

not fixed, make it a private class-level field, not a local variable - so we can reuse it, not recreate per each method call

return false;
UserService usersService = new UserService();
User user = usersService.findByEmail(email);
existUser = Objects.equals(user.getPassword(), password);
Copy link

Choose a reason for hiding this comment

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

I believe we aren't allowed to use Objects class in this task 🥲

Comment on lines 18 to 25
User returnedUser = new User(null,null);

for (User user : users) {
if (email.equals(user.getEmail())) {
returnedUser = user;
}
}
return returnedUser;
Copy link

Choose a reason for hiding this comment

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

Suggested change
User returnedUser = new User(null,null);
for (User user : users) {
if (email.equals(user.getEmail())) {
returnedUser = user;
}
}
return returnedUser;
for (User user : users) {
if (email.equals(user.getEmail())) {
return user;
}
}
return null;

@AnMishkin AnMishkin requested a review from okuzan January 17, 2024 08:52
public class AuthenticationService {
private boolean existUser;
Copy link

Choose a reason for hiding this comment

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

Suggested change
private boolean existUser;

Comment on lines 20 to 27
if (user != null) {
if (user.getPassword() == password) {
existUser = true;
}
} else {
existUser = false;
}
return existUser;
Copy link

Choose a reason for hiding this comment

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

Suggested change
if (user != null) {
if (user.getPassword() == password) {
existUser = true;
}
} else {
existUser = false;
}
return existUser;
return user != null && user.getPassword() == password;

@AnMishkin AnMishkin requested a review from okuzan January 17, 2024 12:34
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.

4 participants