Example #1
0
        public bool Exists(string username, string password)
        {
            IUserSecretAccessor secretAccessor = new UserSecretAccessor();

            IPasswordEncryptor passwordEncryptor = new Sha1PasswordEncryptor();
            string             encryptedPassword = passwordEncryptor.Encrypt(password);

            UserSecret userSecret = secretAccessor.GetSecretForUsername(username);

            return(encryptedPassword == userSecret?.Password);
        }
Example #2
0
        public UserSecret CreateNew(string username, string password)
        {
            IUserSecretAccessor secretAccessor = new UserSecretAccessor();

            IPasswordEncryptor passwordEncryptor = new Sha1PasswordEncryptor();
            string             encryptedPassword = passwordEncryptor.Encrypt(password);

            return(secretAccessor.InsertNewSercret(new UserSecret
            {
                Username = username,
                Password = encryptedPassword
            }));
        }
Example #3
0
        public UserSecret Modify(string username, string password)
        {
            IUserSecretAccessor secretAccessor = new UserSecretAccessor();

            IPasswordEncryptor passwordEncryptor = new Sha1PasswordEncryptor();
            string             encryptedPassword = passwordEncryptor.Encrypt(password);

            return(secretAccessor.ModifySecret(new UserSecret
            {
                Username = username,
                Password = encryptedPassword
            }));
        }