예제 #1
0
        public void Verify_Entered_Password()
        {
            //Arrage
            string password = "******";

            //Act
            var protect = passwordProtector.Protect(password);

            //Assert
            Assert.True(passwordProtector.Verify(password, protect.hash, protect.salt));
        }
        public ClaimsIdentity GetIdentity(string username, string password)
        {
            var user = userRepository.Find(x => x.Email == username);

            if (user == null)
            {
                return(null);
            }

            if (!passwordProtector.Verify(password, user.Password, user.Salt))
            {
                return(null);
            }

            var claims = new[] {
                new Claim(ClaimsIdentity.DefaultNameClaimType, user.Email)
            };

            var identity = new ClaimsIdentity(claims, "Token", ClaimsIdentity.DefaultNameClaimType, null);

            return(identity);
        }