Last active
October 9, 2025 17:27
-
-
Save trikitrok/b27839ce7dd82f60b42c1fe43dcd88ea to your computer and use it in GitHub Desktop.
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
| namespace Security; | |
| public class SimulatedSecurityManager | |
| { | |
| private readonly Encrypter _encrypter; | |
| private readonly Notifier _notifier; | |
| private readonly TextUserDataRequester _userDataRequester; | |
| public SimulatedSecurityManager(Notifier notifier, InputReader inputReader) | |
| { | |
| _notifier = notifier; | |
| _userDataRequester = new TextUserDataRequester(inputReader); | |
| _encrypter = new Encrypter(); | |
| } | |
| public void CreateValidUser() | |
| { | |
| var userData = _userDataRequester.Request(); | |
| if (userData.PasswordsDoNotMatch()) | |
| { | |
| NotifyPasswordDoNotMatch(); | |
| return; | |
| } | |
| if (userData.IsPasswordToShort()) | |
| { | |
| NotifyPasswordIsToShort(); | |
| return; | |
| } | |
| NotifyUserCreation(userData); | |
| } | |
| private void NotifyPasswordIsToShort() | |
| { | |
| _notifier.Notify("Password must be at least 8 characters in length"); | |
| } | |
| private void NotifyPasswordDoNotMatch() | |
| { | |
| _notifier.Notify("The passwords don't match"); | |
| } | |
| private void NotifyUserCreation(UserData userData) | |
| { | |
| _notifier.Notify( | |
| $"Saving Details for User ({userData.UserName()}, {userData.FullName()}, {userData.EncryptPassword(_encrypter)})\n" | |
| ); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment