Skip to content

Instantly share code, notes, and snippets.

@trikitrok
Last active October 9, 2025 17:27
Show Gist options
  • Select an option

  • Save trikitrok/b27839ce7dd82f60b42c1fe43dcd88ea to your computer and use it in GitHub Desktop.

Select an option

Save trikitrok/b27839ce7dd82f60b42c1fe43dcd88ea to your computer and use it in GitHub Desktop.
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