コード例 #1
0
        public void Authentication_fails_on_wrong_PINs(string wrongPin)
        {
            string testPin = "2345";

            AddMockUserToCache("gerald", "Gerald Kyp", "password234", testPin);
            Authentication auth = new PinAuthentication();

            auth.SetUsers(UserCache.Records);

            Credentials pinCredentials = auth.GetEmptyCredentials();

            pinCredentials.Secret = wrongPin;

            Assert.False(auth.IsValidFor(pinCredentials), "PINs should not match");
        }
コード例 #2
0
        public void Users_may_authenticate_using_a_PIN()
        {
            string testPin = "2345";

            AddMockUserToCache("gerald", "Gerald Kyp", "password234", testPin);
            Authentication auth = new PinAuthentication();

            auth.SetUsers(UserCache.Records);

            Credentials pinCredentials = auth.GetEmptyCredentials();

            pinCredentials.Secret = testPin;

            Assert.True(auth.IsValidFor(pinCredentials), "PINs do not match");
        }
コード例 #3
0
        private void ProcessLoginCredentials()
        {
            if (String.IsNullOrWhiteSpace(passwordTxt.Text) == false)
            {
                string pin = passwordTxt.Text;

                Authentication authentication = new PinAuthentication();
                authentication.SetUsers(UserCache.Records);
                Credentials pinCredentials = authentication.GetEmptyCredentials();
                pinCredentials.Secret = pin;

                if (authentication.IsValidFor(pinCredentials))
                {
                    UserDaoFactory daoFactory = new UserDaoFactory();
                    UserDao        dao        = daoFactory.GenerateDao();
                    LoginUser    = UserCache.PINLookup(pin);
                    DialogResult = DialogResult.OK;
                }
            }
        }