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 Guid GetId()
        {
            var userRepository = new UserRepository();
            UserEntity userEntity = userRepository.GetBy(Email);

            if (userEntity == null)
            {
                throw new UserNotFoundException();
            }

            return userEntity.Id;
        }
        public void Confirm(string userId)
        {
            var userRepository = new UserRepository();

            var userEntity = userRepository.GetBy(GetGuidBy(userId));

            if (userEntity.IsConfirmed)
            {
                return;
            }

            userEntity.IsConfirmed = true;
            userRepository.SaveChanges();
        }
        public void Initialize()
        {
            efStorage = new EfStorage(new EfStorageDbInitializerTest());
            efStorage.Database.Initialize(true);

            repository = new UserRepository();

            userEntity = new UserEntity()
            {
                Id = Guid.NewGuid(),
                Name = "Foo",
                Email = "*****@*****.**",
                HashedPassword = "******",
            };
        }
        public override string[] GetRolesForUser(string id)
        {
            if (string.IsNullOrEmpty(id))
            {
                throw new ProviderException("Email cannot be empty or null.");
            }

            Guid parsedGuid;
            if (Guid.TryParse(id, out parsedGuid))
            {
                var userRepository = new UserRepository();
                var userEntity = userRepository.GetBy(parsedGuid);

                return userEntity.Roles.Select(x => x.Name).ToArray();
            }
            return null;
        }
        public void Confirm_UserIdIsValidAndExists_SetIsConfirmedPropertyToTrue()
        {
            var userRegistrationModel = new UserRegistrationModel
            {
                Name = "name",
                Email = "*****@*****.**",
                Password = "******",
                ConfirmedPassword = "******"
            };

            userRegistrationModel.Save();

            registrationConfirmationModel.Confirm(userRegistrationModel.Id.ToString());

            var retrievedEntity = new UserRepository().GetBy(userRegistrationModel.Id);

            Assert.AreEqual(retrievedEntity.IsConfirmed, true);
        }
        public void GetId_ReturnsUserIdBasedOnEmail()
        {
            const string email = "*****@*****.**";

            UserRegistrationModel userRegistrationModel = new UserRegistrationModel
            {
                Name = "nume",
                Email = email,
                Password = "******",
                ConfirmedPassword = "******",
            };
            userRegistrationModel.Save();

            UserEntity expectedUser = new UserRepository().GetBy(email);

            var actualUser = new RecoverPasswordModel
            {
                Email = email
            };

            Assert.AreEqual(expectedUser.Id, actualUser.GetId());
        }
 public UserRegistrationModel()
 {
     userRepository = new UserRepository();
     Id = Guid.NewGuid();
 }
        public override bool IsValid(object value)
        {
            var userRepository = new UserRepository();

            return userRepository.GetBy((string)value) == null;
        }