-
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
write in AuthenticationService - login method and in class UserServic… #908
base: master
Are you sure you want to change the base?
Conversation
…e - findByEmail method
return false; | ||
boolean existUser; | ||
|
||
UserService users = 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.
move to the class field
User equalsUser; | ||
equalsUser = users.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 equalsUser; | |
equalsUser = users.findByEmail(email); | |
User user = users.findByEmail(email); |
return false; | ||
boolean existUser; | ||
|
||
UserService users = 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.
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; |
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.
boolean existUser; |
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.
in this recommendation,i understand what you mean
User equalsUser; | ||
equalsUser = users.findByEmail(email); | ||
|
||
if (equalsUser.getPassword() == 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.
how we need equal string? :)
if (equalsUser.getPassword() == password) { | ||
existUser = true; | ||
} else { | ||
existUser = false; | ||
} | ||
|
||
return existUser; |
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.
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(); |
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.
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); |
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.
I believe we aren't allowed to use Objects class in this task 🥲
User returnedUser = new User(null,null); | ||
|
||
for (User user : users) { | ||
if (email.equals(user.getEmail())) { | ||
returnedUser = user; | ||
} | ||
} | ||
return returnedUser; |
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 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; |
public class AuthenticationService { | ||
private boolean existUser; |
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.
private boolean existUser; |
if (user != null) { | ||
if (user.getPassword() == password) { | ||
existUser = true; | ||
} | ||
} else { | ||
existUser = false; | ||
} | ||
return existUser; |
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.
if (user != null) { | |
if (user.getPassword() == password) { | |
existUser = true; | |
} | |
} else { | |
existUser = false; | |
} | |
return existUser; | |
return user != null && user.getPassword() == password; |
…e - findByEmail method