Created
June 6, 2015 14:43
-
-
Save tzachz/ce659af0be7676e23730 to your computer and use it in GitHub Desktop.
Functions should not have side effects (from Clean Code, p.44)
This file contains hidden or 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
| public class UserValidator { | |
| private Cryptographer cryptographer; | |
| public boolean checkPassword(String userName, String password) { | |
| User user = UserGateway.findByName(userName); | |
| if (user != User.NULL) { | |
| String codedPhrase = user.getPhraseEncodedByPassword(); | |
| String phrase = cryptographer.decrypt(codedPhrase, password); | |
| if ("Valid Password".equals(phrase)) { | |
| Session.initialize(); | |
| return true; | |
| } | |
| } | |
| return false; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment