예제 #1
0
        private void SendDataToDatabase()
        {
            var profileData = UserFactory.ChangePassword(
                Response.Cookies["UserUsername"]?.Value.ToString(),
                PasswordConfirmInput.Text);

            UserRepository.ChangePassword(profileData);
        }
예제 #2
0
        public async Task ChangePassword(UserChangePasswordModel model)
        {
            var item = await _repository.GetAsync(model.Id);

            UserFactory.ChangePassword(model, item, _userId);
            _repository.ChangePassword(item);
            await _unitOfWork.SaveChangesAsync();
        }
예제 #3
0
        public ActionResult ChangePassword(UserChangePassword user)
        {
            if (!CheckLogin())
            {
                return(RedirectToAction("Login", "User"));
            }

            ViewBag.Roles   = _roleFactory.GetSelectListRole();
            ViewBag.Clients = _clientFactory.GetSelectListClient();
            ViewBag.Edit    = true;

            ModelState.Remove("Updated");

            if (!ModelState.IsValid)
            {
                return(View(user));
            }

            user = _userFactory.ChangePassword(user);

            switch (user.Updated)
            {
            case 0:
                ModelState.AddModelError("", "Invalid username or password");
                break;

            case 1:
                ModelState.AddModelError("", "New pasword can not be the same as the old password");
                break;

            case 2:
                ModelState.AddModelError("", "New password and confirm new password must be the same");
                break;
            }

            return(View(user));
        }