コード例 #1
0
        public void AddNewAccount_Success()
        {
            BCryptHashGenerator hashGenerator = new BCryptHashGenerator();
            string salt = hashGenerator.GenerateSalt();
            string encryptedPassword = hashGenerator.GenerateEncryptedString("adahplf0015", salt);

            Account account = new Account()
            {
                EmailAddress     = "*****@*****.**",
                Username         = "******",
                Password         = encryptedPassword,
                Salt             = salt,
                EmailWasVerified = true,
                ActivationToken  = "3df4h",
                RecoveryToken    = "df567"
            };
            Player player = new Player()
            {
                EmailAddress = "*****@*****.**",
                Score        = 0
            };

            UnitOfWork unitOfWork = new UnitOfWork(new MemoryGameContext());

            unitOfWork.Players.Add(player);
            unitOfWork.Complete();

            unitOfWork.Accounts.Add(account);
            int expected = 1;
            int actual   = unitOfWork.Complete();

            Assert.AreEqual(expected, actual);
        }
コード例 #2
0
        private void HashAccountPassword()
        {
            BCryptHashGenerator bCryptHashGenerator = new BCryptHashGenerator();
            string salt           = bCryptHashGenerator.GenerateSalt();
            string hashedPassword = bCryptHashGenerator.GenerateHashedString(Coordinator.User.Account.Password, salt);

            Coordinator.User.Account.Password = hashedPassword;
        }
コード例 #3
0
ファイル: Login.xaml.cs プロジェクト: AdairHdz/memory
        private bool LoginIsValid()
        {
            BCryptHashGenerator bCryptHashGenerator = new BCryptHashGenerator();
            string salt = GetPasswordSalt();
            string encryptedPassword = bCryptHashGenerator.GenerateEncryptedString(_password, salt);
            bool   hasAccessRights   = _accessibilityServiceClient.HasAccessRights(_username, encryptedPassword);

            return(hasAccessRights);
        }
コード例 #4
0
        private void HashAccountPassword()
        {
            BCryptHashGenerator bCryptHashGenerator = new BCryptHashGenerator();
            string salt           = bCryptHashGenerator.GenerateSalt();
            string hashedPassword = bCryptHashGenerator.GenerateHashedString(Practicioner.User.Account.Password, salt);

            Practicioner.User.Account.Password = hashedPassword;
            Practicioner.User.Account.Salt     = salt;
        }
コード例 #5
0
ファイル: FirstLogin.xaml.cs プロジェクト: AdairHdz/SPP
        private void HashAccountPassword()
        {
            BCryptHashGenerator bCryptHashGenerator = new BCryptHashGenerator();
            string salt = bCryptHashGenerator.GenerateSalt();

            account.Salt = salt;
            string hashedPassword = bCryptHashGenerator.GenerateHashedString(account.Password, salt);

            account.Password = hashedPassword;
        }
コード例 #6
0
ファイル: Login.xaml.cs プロジェクト: AdairHdz/SPP
        private bool IsValidAccountPassword()
        {
            BCryptHashGenerator bCryptHashGenerator = new BCryptHashGenerator();
            string hashedPassword = bCryptHashGenerator.GenerateHashedString(accountCurrent.Password, accountReceived.Salt);

            accountCurrent.Password = hashedPassword;
            _password = hashedPassword;
            AccountValidator          accountValidator     = new AccountValidator(accountReceived);
            ValidationResult          dataValidationResult = accountValidator.Validate(accountCurrent);
            IList <ValidationFailure> validationFailures   = dataValidationResult.Errors;
            UserFeedback userFeedback = new UserFeedback(FormGrid, validationFailures);

            userFeedback.ShowFeedback();
            return(dataValidationResult.IsValid);
        }
コード例 #7
0
ファイル: LoginTest.cs プロジェクト: AdairHdz/SPP
        public void SaveAccount()
        {
            try
            {
                var accountCurrent = _unitOfWork.Accounts.Get(1);
                BCryptHashGenerator bCryptHashGenerator = new BCryptHashGenerator();
                string salt           = bCryptHashGenerator.GenerateSalt();
                string hashedPassword = bCryptHashGenerator.GenerateHashedString("MMOL78945", salt);
                accountCurrent.Password = hashedPassword;
                accountCurrent.Salt     = salt;
            }
            catch (System.NullReferenceException)
            {
            }
            int expected = 1;
            int actual   = _data.Count;

            Assert.AreEqual(expected, actual);
        }
コード例 #8
0
        private bool PlayerWasSuccessfullyRegistered()
        {
            BCryptHashGenerator hashGenerator = new BCryptHashGenerator();
            string salt = hashGenerator.GenerateSalt();
            string encryptedPassword = hashGenerator.GenerateEncryptedString(_password, salt);

            MemoryGameService.PlayerRegistryServiceClient playerRegistryServiceClient =
                new MemoryGameService.PlayerRegistryServiceClient();

            PlayerDto playerDTO = new PlayerDto()
            {
                Username          = _username,
                EmailAddress      = _emailAddress,
                Password          = encryptedPassword,
                VerificationToken = _verificationToken
            };

            bool playerWasSuccessfullyRegistered = playerRegistryServiceClient.RegisterNewPlayer(playerDTO, salt);

            return(playerWasSuccessfullyRegistered);
        }
コード例 #9
0
        private bool SetNewPassword()
        {
            IEncryption bCryptHashGenerator = new BCryptHashGenerator();
            string      newPassword         = NewPasswordBox.Password;

            if (newPassword == "")
            {
                return(false);
            }
            string salt = bCryptHashGenerator.GenerateSalt();
            string encryptedNewPassword = bCryptHashGenerator.GenerateEncryptedString(newPassword, salt);
            AccountModifiabilityServiceClient  accountModifiabilityServiceClient = new AccountModifiabilityServiceClient();
            PasswordModificationCredentialsDto passwordModificationCredentials   = new PasswordModificationCredentialsDto()
            {
                EmailAddress = _emailAddress,
                Salt         = salt,
                NewPassword  = encryptedNewPassword
            };
            bool newPasswordWasAssigned = accountModifiabilityServiceClient.SetNewPassword(passwordModificationCredentials);

            return(newPasswordWasAssigned);
        }