public ActionResult ChangePassword(PasswordChangeEntity pasEntity)
        {
            User user = (User)Session["User"];

            byte[] pas = Encoding.Unicode.GetBytes(pasEntity.OldPassword);
            SHA1   sha = new SHA1CryptoServiceProvider();

            pas = sha.ComputeHash(pas);
            if (!pas.SequenceEqual(user.Password))
            {
                return(ErrorView("Невено введён пароль"));
            }

            if (String.Compare(pasEntity.NewPassword, pasEntity.RepeatNewPassword, false) != 0)
            {
                return(ErrorView("Вы неправильно повторили пароль"));
            }

            pas           = Encoding.Unicode.GetBytes(pasEntity.NewPassword);
            user.Password = sha.ComputeHash(pas);

            db.Entry(user).State = EntityState.Modified;
            db.SaveChanges();

            Session["User"]      = user;
            ViewBag.SelectedUser = user;
            ViewBag.User         = user;
            return(View("PersonalArea"));
        }
Esempio n. 2
0
        public virtual async Task <Execute> ChangePasswordAsync(PasswordChangeEntity info)
        {
            var result = new Execute();
            var user   = await UsersBusiness.GetByKeyAsync(TicketManager.UserKey);

            if (user == null)
            {
                result.AddError(Resources.Authentication.InvalidUserPassword);
                return(result);
            }

            if (!await VerifyPasswordHashAsync(user, info.PasswordCurrent))
            {
                result.AddError(Resources.Authentication.PasswordNotMatch);
                return(result);
            }

            if (info.PasswordNew != info.PasswordConfirm)
            {
            }

            user.Action       = EntityAction.Update;
            user.PasswordHash = await GetPasswordHashAsync(user, info.PasswordNew);

            result.AddMessage(await UsersBusiness.SaveAsync(user));

            return(result);
        }
Esempio n. 3
0
        public bool ChangePassword(Guid userId, PasswordChangeEntity passwordEntity)
        {
            User User = context.Users.FirstOrDefault(u => u.Id.Equals(userId));

            if (User == null)
            {
                return(false);
            }
            if (SecurePasswordHasher.Verify(passwordEntity.OldPassword, User.Password))
            {
                //User newPasswordUser = new User(passwordEntity.UserEntity);
                User.Password = SecurePasswordHasher.Hash(passwordEntity.UserEntity.Password);
                context.SaveChanges();
                return(true);
            }
            return(false);
        }
Esempio n. 4
0
 public virtual async Task <Execute> ChangePassword([FromBody] PasswordChangeEntity info)
 {
     info.Key = Ticket.UserKey;
     return(await LoginBusiness.ChangePasswordAsync(info));
 }
Esempio n. 5
0
 public IHttpActionResult ChangePassword(uint id, PasswordChangeEntity password)
 {
     return(this.UserProvider.ChangePassword(id, password.OldPassword, password.NewPassword) ?
            (IHttpActionResult)this.Ok() : this.NotFound());
 }
Esempio n. 6
0
 public Task <Execute> ChangePasswordAsync(PasswordChangeEntity info)
 {
     throw new NotImplementedException();
 }
Esempio n. 7
0
 public bool ChangePassword(Guid UserId, [FromBody] PasswordChangeEntity PasswordEntity)
 {
     return(UserService.ChangePassword(UserId, PasswordEntity));
 }