Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .vs/VSWorkspaceState.json
Copy link
Contributor

Choose a reason for hiding this comment

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

this file and .vs directory shouldn't be added to git and pushed to github

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"ExpandedNodes": [
""
],
"PreviewInSolutionExplorer": false
}
Binary file added .vs/jv-oop-lesson-0/v17/.wsuo
Binary file not shown.
12 changes: 12 additions & 0 deletions .vs/jv-oop-lesson-0/v17/DocumentLayout.json
Copy link
Contributor

Choose a reason for hiding this comment

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

this file and .vs directory shouldn't be added to git and pushed to github

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"Version": 1,
"WorkspaceRootPath": "C:\\Users\\sofyh\\Source\\Repos\\jv-oop-lesson-0\\",
"Documents": [],
"DocumentGroupContainers": [
{
"Orientation": 0,
"VerticalTabListWidth": 256,
"DocumentGroups": []
}
]
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package mate.academy.service;

import mate.academy.model.User;

public class AuthenticationService {
/**
* Imagine that some user wants to login to your site.
Expand All @@ -11,6 +13,11 @@ public class AuthenticationService {
* Return false in any other cases.
*/
public boolean login(String email, String password) {
return false;
User user = UserService.findByEmail(email);
if (user != null && user.getPassword().equals(password)) {
return true;
} else {
return false;
}
}
}
9 changes: 8 additions & 1 deletion src/main/java/mate/academy/service/UserService.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,14 @@ public class UserService {
* @return - user if his email is equal to passed email.
* Return <code>null</code> if there is no suitable user
*/
public User findByEmail(String email) {
public static User findByEmail(String email) {
for (int i = 0; i < users.length; i++) {
if (users[i].getEmail().equals(email)) {
return users[i];
} else {
continue;
}

Choose a reason for hiding this comment

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

Suggested change
if (users[i].getEmail().equals(email)) {
return users[i];
} else {
continue;
}
if (user.getEmail().equals(email)) {
return user;
}

Copy link
Author

Choose a reason for hiding this comment

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

Тобто тут краще використати цикл for each замість звичайного for?

}
return null;
}
}