-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add UserExistsMiddleware - ConcreteHandler (Filtering Access - Chain …
…Of Responsibility)
- Loading branch information
1 parent
01a2f59
commit 2d694cc
Showing
1 changed file
with
29 additions
and
0 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
ChainOfResponsability/FilteringAccess/UserExistsMiddleware.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// ConcreteHandler | ||
public class UserExistsMiddleware extends BaseMiddleware{ | ||
private Server server; | ||
|
||
//! Constructor replaced by link method | ||
//public UserExistsMiddleware(BaseMiddleware m){ | ||
// this.next = m; | ||
//} | ||
|
||
public UserExistsMiddleware(Server s) { | ||
this.server = s; | ||
} | ||
|
||
// handlerRequest method | ||
@Override | ||
public boolean check(String email, String password) { | ||
if(!server.hasEmail(email)){ | ||
System.out.println("This email is not registered"); | ||
return false; | ||
} | ||
if (!server.isValidPassword(email, password)) { | ||
System.out.println("Wrong password"); | ||
return false; | ||
} | ||
|
||
return checkNext(email, password); | ||
} | ||
} | ||
|