public void SetPassword()
        {
            var userRepository = new UserRepository();
            var userEntity = userRepository.GetBy(Id);

            var password = new Password(ConfirmedPassword);
            userEntity.HashedPassword = password.GetHashed();
            userEntity.Salt = password.GetSalt();

            userRepository.SaveChanges();
        }
Ejemplo n.º 2
0
        public void SetPassword()
        {
            var userRepository = new UserRepository();
            var userEntity     = userRepository.GetBy(Id);

            var password = new Password(ConfirmedPassword);

            userEntity.HashedPassword = password.GetHashed();
            userEntity.Salt           = password.GetSalt();

            userRepository.SaveChanges();
        }
        public bool Authenthicate()
        {
            var userEntity = repository.GetBy(Email);

            if (userEntity == null || !userEntity.IsConfirmed)
            {
                return(false);
            }

            FromEntity(userEntity);

            var password = new Password(Password, userEntity.Salt);

            return(userEntity.HashedPassword == password.GetHashed());
        }
        private UserEntity ToUserEntity()
        {
            var password = new Password(Password);

            var userEntity = new UserEntity
            {
                Name           = Name,
                Email          = Email,
                IsConfirmed    = false,
                Id             = Id,
                Salt           = password.GetSalt(),
                HashedPassword = password.GetHashed(),
            };

            userEntity.Roles.Add(new RoleRepository().GetRole(Role.Regular));

            return(userEntity);
        }
        private UserEntity ToUserEntity()
        {
            var password = new Password(Password);

            var userEntity = new UserEntity
            {
                Name = Name,
                Email = Email,
                IsConfirmed = false,
                Id = Id,
                Salt = password.GetSalt(),
                HashedPassword = password.GetHashed(),
            };

            userEntity.Roles.Add(new RoleRepository().GetRole(Role.Regular));

            return userEntity;
        }
        public void GetHashed_IsDifferentThanClearPassword()
        {
            var password = new Password(ClearTextPassword, "salt");

            Assert.AreNotEqual(ClearTextPassword, password.GetHashed());
        }
        public bool Authenthicate()
        {
            var userEntity = repository.GetBy(Email);
            if (userEntity == null || !userEntity.IsConfirmed)
            {
                return false;
            }

            FromEntity(userEntity);

            var password = new Password(Password, userEntity.Salt);

            return userEntity.HashedPassword == password.GetHashed();
        }