Ejemplo n.º 1
0
        public async Task AddAsync(ChangePassword entity)
        {
            User user     = Uow.Repository <User>().SingleOrDefault(t => t.UserId == entity.UserId);
            bool password = PasswordHash.VerifySignature(entity.OldPassword.ToString(), user.Password, user.Salt);

            if (password)
            {
                PasswordResult passwordResult = PasswordHash.Encrypt(entity.NewPassword);
                user.Password = passwordResult.Signature;
                user.Salt     = passwordResult.Salt;
                await this.UpdateAsync(user);
            }
            //await Uow.RegisterNewAsync(entity);
            //await Uow.CommitAsync();
        }
        public async Task <object> GetAsync(ChangePassword parameters)
        {
            User user     = Uow.Repository <User>().SingleOrDefault(t => t.UserId == parameters.UserId);
            bool password = PasswordHash.VerifySignature(parameters.OldPassword.ToString(), user.Password, user.Salt);

            if (password)
            {
                PasswordResult passwordResult = PasswordHash.Encrypt(parameters.NewPassword);
                user.Password = passwordResult.Signature;
                user.Salt     = passwordResult.Salt;
                await this.UpdateAsync(user);

                return(true);
            }
            else
            {
                return(false);
            }
        }