Esempio n. 1
0
        public async Task <IActionResult> ChangePassword(ChangePasswordRequest request)
        {
            if (!ModelState.IsValid)
            {
                return(RedirectToAction(nameof(Index)));
            }

            Result result = await _credentialsService.ChangePassword(GetUserId(), GetSessionCode(), GetIp(), request);

            if (result.Failure)
            {
                SaveTempData(STATUS_ALERT_TEMP_DATA_KEY, StatusAlertViewExtension.Get(result));
            }
            else
            {
                SaveTempData(STATUS_ALERT_TEMP_DATA_KEY, StatusAlertViewExtension.Get("Password was updated"));
            }

            return(RedirectToAction(nameof(Index)));
        }
Esempio n. 2
0
        public async Task <IActionResult> ChangePassword(ChangePasswordRequest request)
        {
            if (!ModelState.IsValid)
            {
                return(RedirectToAction(nameof(Index)));
            }

            Result result = await _credentialsService.ChangePassword(GetUserId(), GetSessionCode(), GetIp(), request);

            ChangePasswordViewModel viewModel;

            if (result.Failure)
            {
                viewModel = new ChangePasswordViewModel(StatusAlertViewExtension.Get(result));

                ModelState.AddErrors(result.Errors);
                return(View(viewModel));
            }
            viewModel = new ChangePasswordViewModel(StatusAlertViewExtension.Get("Password updated"));

            return(View(viewModel));
        }