コード例 #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
ファイル: 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);
        }
コード例 #3
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);
        }
コード例 #4
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);
        }