public async Task <IHttpActionResult> InternalPasswordReset([FromBody] ClientsResetPasswordModel model)
        {
            if (!ModelState.IsValid)
            {
                return(Content(HttpStatusCode.BadRequest, GetValidationErrors()));
            }

            var client = await _clientService.FindById(model.Id);

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

            if (!client.UserLoginData.IsActive)
            {
                ModelState.AddModelError("reset_password", Resource.UserAccountNotActive);
                return(Content(HttpStatusCode.BadRequest, GetValidationErrors()));
            }

            if (string.IsNullOrEmpty(client.Email))
            {
                ModelState.AddModelError("reset_password", Resource.UserHasNotEnteredEmail);
                return(Content(HttpStatusCode.BadRequest, GetValidationErrors()));
            }
            try
            {
                await _passwordRecoveryService.ResetPasswordAndSendEmail(client, model.Length, model.SpecialCharacters);
            } catch (Exception e)
            {
                return(InternalServerError(e));
            }
            return(Ok());
        }
Ejemplo n.º 2
0
        public async Task <ActionResult> ResetPassword(string clientId)
        {
            var response = await _httpClientService.GetJsonContent("api/maintenance/adminsettings");

            if (response.IsSuccessStatusCode)
            {
                var content = await response.Content.ReadAsAsync <MaintenanceEditModel>();

                var passwordLength    = content != null ? content.PasswordLength : 0;
                var specialCharacters = content != null ? content.PasswordSpecialCharacters : 0;

                var model = new ClientsResetPasswordModel
                {
                    Id                        = clientId,
                    PasswordLength            = passwordLength,
                    PasswordSpecialCharacters = specialCharacters,
                    Length                    = passwordLength,
                    SpecialCharacters         = specialCharacters
                };

                return(PartialView("_ResetPassword", model: model));
            }

            return(HttpNotFound());
        }
Ejemplo n.º 3
0
        public async Task <ActionResult> ResetPassword(ClientsResetPasswordModel model)
        {
            if (!ModelState.IsValid)
            {
                return(PartialView("_ResetPassword", model: model));
            }

            var response = await _httpClientService
                           .SendRequest("api/user/maintenance/resetpassword/internal", HttpMethod.Put, model);

            if (response.IsSuccessStatusCode)
            {
                return(NotificationSuccessResult(Resource.UserPasswordResetSuccess));
            }

            var errorMessage = await _commonService.CheckForValidationErrors(response, Resource.ApplicationErrorText);

            return(NotificationErrorResult(errorMessage));
        }