Esempio n. 1
0
        public async Task <IActionResult> OnPostSubmit()
        {
            ModelState.Remove("Input.UserName");
            ModelState.Remove("Input.FirstName");
            ModelState.Remove("Input.MiddleName");
            ModelState.Remove("Input.LastName");
            ModelState.Remove("Input.BirthDateString");
            ModelState.Remove("Input.Address");
            ModelState.Remove("Input.GenderId");
            ModelState.Remove("Input.PhoneNumber");
            ModelState.Remove("Input.Email");


            if (!ModelState.IsValid)
            {
                return(Page());
            }

            var result = await UsersService.ChangePassword(new ReturnResult <UserViewModel>() { Value = Input });

            ModelState.Merge(result);

            if (!ModelState.IsValid)
            {
                return(Page());
            }

            ShowMessage(CoreEnumerations.MessageTypes.info, UsersResources.ChangePasswordSuccessfully);

            return(RedirectToPage("/Users/Index", new { area = "UserManagementAdmin" }));
        }
Esempio n. 2
0
        public IActionResult ChangePassword(long id, [FromBody] PasswordChangeRequest request)
        {
            var user = UsersService.ChangePassword(id, request);

            if (user == null)
            {
                return(NotFound());
            }

            return(Ok(user));
        }
Esempio n. 3
0
 public async Task <IHttpActionResult> ChangePassword(ChangePasswordDto dto)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest(ModelState));
     }
     if (!await usersService.ChangePassword(dto, User.Identity.GetUserId <int>()))
     {
         return(BadRequest());
     }
     return(Ok());
 }
        public ActionResult ChangePassword(Users user)
        {
            var us = (Users)Session["User"];

            if (us != null && us.UserID != user.UserID)
            {
                return(RedirectToAction("Login", "Home", new { area = "" }));
            }
            var res = UsersService.ChangePassword(user.UserID, user.Password);

            Session["User"] = UsersService.CheckUsers(user.Username, user.Password);
            return(Json(res, JsonRequestBehavior.AllowGet));
        }
Esempio n. 5
0
        public IActionResult ChangePassword([FromBody] UserDto userDto)
        {
            string password = userDto.Password;
            string username = userDto.Username;

            // map dto to entity and set id
            //var user = Mapper.Map<User>(userDto);

            try
            {
                // save
                UsersService.ChangePassword(username, password);
                return(Ok());
            }
            catch (Exception ex)
            {
                // return error message if there was an exception
                return(BadRequest(new { message = ex.Message }));
            }
        }
        public async Task <IActionResult> UpdateChangePassword([FromBody] CustomerRegistrationDto CustomerRegistrationDto)
        {
            try
            {
                var _types = await _UsersService.LoginAuthenticate(CustomerRegistrationDto);

                if (_types != null)
                {
                    if (!String.IsNullOrEmpty(CustomerRegistrationDto.OldPWD))
                    {
                        if (EncryptionHelper.Decrypt(_types.PWD) == CustomerRegistrationDto.OldPWD)
                        {
                            var list = (from t in _types.UserAduit
                                        orderby t.CreatedDate descending
                                        select t).Take(3);

                            foreach (var Auditloop in list)
                            {
                                if (EncryptionHelper.Decrypt(Auditloop.Newvalue) == CustomerRegistrationDto.PWD)
                                {
                                    return(BadRequest(new GenericResultDto <string>
                                    {
                                        Result = "Choose a password that is different from your last 3 passwords"
                                    }));
                                }
                            }
                            if (EncryptionHelper.Decrypt(_types.PWD) != CustomerRegistrationDto.PWD)
                            {
                                await _UsersService.ChangePassword(CustomerRegistrationDto);

                                await _OTPAuthenticationService.DeleteOTPVerifydetails(CustomerRegistrationDto);

                                return(Ok(new GenericResultDto <string> {
                                    Result = "Your password has been changed"
                                }));
                            }
                            else
                            {
                                return(BadRequest(new GenericResultDto <string>
                                {
                                    Result = "Choose a password that is different from your last 3 passwords"
                                }));
                            }
                        }
                        else
                        {
                            return(BadRequest(new GenericResultDto <string> {
                                Result = "The old password you have entered is incorrect"
                            }));
                        }
                    }
                    else
                    {
                        var list = (from t in _types.UserAduit
                                    orderby t.CreatedDate descending
                                    select t).Take(3);

                        foreach (var Auditloop in list)
                        {
                            if (EncryptionHelper.Decrypt(Auditloop.Newvalue) == CustomerRegistrationDto.PWD)
                            {
                                return(BadRequest(new GenericResultDto <string>
                                {
                                    Result = "Choose a password that is different from your last 3 passwords"
                                }));
                            }
                        }
                        if (EncryptionHelper.Decrypt(_types.PWD) != CustomerRegistrationDto.PWD)
                        {
                            await _UsersService.ChangePassword(CustomerRegistrationDto);

                            await _OTPAuthenticationService.DeleteOTPVerifydetails(CustomerRegistrationDto);

                            return(Ok(new GenericResultDto <string> {
                                Result = "Your password has been changed"
                            }));
                        }
                        else
                        {
                            return(BadRequest(new GenericResultDto <string>
                            {
                                Result = "Choose a password that is different from your last 3 passwords"
                            }));
                        }
                    }
                }
                else
                {
                    return(BadRequest(new GenericResultDto <string> {
                        Result = "Invalid email"
                    }));
                }
            }
            catch (Exception err)
            {
                return(BadRequest(new GenericResultDto <string> {
                    Result = err.Message
                }));
            }
            return(Ok(new GenericResultDto <string> {
                Result = "Your password has been changed"
            }));
        }
Esempio n. 7
0
        public IActionResult ChangeCurrentUserPassword([FromBody] PasswordChangeRequest request)
        {
            var currentUserID = HttpContext.User.GetUserID();

            return(Ok(UsersService.ChangePassword(currentUserID, request)));
        }