Skip to content

Commit

Permalink
make some changes
Browse files Browse the repository at this point in the history
  • Loading branch information
DankevichMisha committed Oct 28, 2024
1 parent f0885b8 commit 980be9a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,8 @@ public class AuthenticationService {
* Return false in any other cases.
*/
public boolean login(String email, String password) {
boolean a = true;
for (int i = 0; i < users.length; i++) {
if (email.equals(users[i].getEmail()) && password.equals(users[i].getPassword())) {
a = true;
}
else a = false;
}
return a;
UserService userService = new UserService();
User user = userService.findByEmail(email);
return user != null && user.getPassword().equal(password);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ public class UserService {
* @return - user if his email is equal to passed email.
* Return <code>null</code> if there is no suitable user
*/
public String findByEmail(String email) {
String a = null;
for (int i = 0; i < users.length; i++)
if (email.equals(users[i].getEmail())) {
a = String.valueOf(users[i]);
public User findByEmail(String email) {
for (User user : users) {
if (user.getEmail().equals(email)) {
return user;
}
return a;
}
return null;
}
}
}

0 comments on commit 980be9a

Please sign in to comment.