Skip to content

Conversation

@Vitalii85
Copy link

No description provided.

Copy link

@liliia-ponomarenko liliia-ponomarenko left a comment

Choose a reason for hiding this comment

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

Good job! A few comments ;)

* Return <code>null</code> if there is no suitable user
*/
public User findByEmail(String email) {
public static User findByEmail(String email) {

Choose a reason for hiding this comment

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

Suggested change
public static User findByEmail(String email) {
publiс User findByEmail(String email) {

Don't make this method static

Comment on lines 14 to 15
return (UserService.findByEmail(email) == null) ? false
: UserService.findByEmail(email).getPassword().equals(password);

Choose a reason for hiding this comment

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

Make UserService class-level variable. Call the method findByEmail only once

*/
public boolean login(String email, String password) {
return false;
UserService userService = 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

@Vitalii85 Vitalii85 requested a review from Elena-Bruyako July 30, 2025 15:51
Copy link

@Elena-Bruyako Elena-Bruyako left a comment

Choose a reason for hiding this comment

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

one comment

* @return true if user by email exists and passed password is equal to user's password.
* Return false in any other cases.
*/
private static final UserService userService = new UserService();

Choose a reason for hiding this comment

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

never create static mutable object

Suggested change
private static final UserService userService = new UserService();
private final UserService userService = new UserService();

@Vitalii85 Vitalii85 requested a review from Elena-Bruyako July 30, 2025 16:36
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.

3 participants