Skip to content

Commit

Permalink
create HW
Browse files Browse the repository at this point in the history
  • Loading branch information
boroda4436 authored and jekaGr committed Dec 22, 2024
1 parent 4ab19ad commit 45c39fc
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ jobs:

steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
java-version: '11'
java-version: '17'
distribution: 'adopt'
cache: maven
- name: Build with Maven
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/mate/academy/service/AuthenticationService.java
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 @@ -10,7 +12,15 @@ public class AuthenticationService {
* @return true if user by email exists and passed password is equal to user's password.
* Return false in any other cases.
*/
private UserService service = new UserService();

public boolean login(String email, String password) {
User user = service.findByEmail(email);
if (user == null) {
return false;
} else if (user.getPassword().equals(password)) {
return true;
}
return false;
}
}
5 changes: 5 additions & 0 deletions src/main/java/mate/academy/service/UserService.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ public class UserService {
* Return <code>null</code> if there is no suitable user
*/
public User findByEmail(String email) {
for (User user : users) {
if (user.getEmail().equals(email)) {
return user;
}
}
return null;
}
}

0 comments on commit 45c39fc

Please sign in to comment.