public ActionResult Userdetail(string username) { GenericAjaxResponse <AHP.Core.DTO.ExternalUserInfo> response = new GenericAjaxResponse <Core.DTO.ExternalUserInfo>(); try { if (string.IsNullOrEmpty(username)) { response.Success = false; response.Errors.Add("Please provider a username"); return(Json(response)); } response = _restClient.GetUserDetails(username); if (response == null) { response = new GenericAjaxResponse <Core.DTO.ExternalUserInfo>(); response.Success = false; response.Errors.Add("An error occurred. Please try again."); } } catch (Exception ex) { response.Success = false; response.Errors.Add("Error occurred."); _logger.Error("Error occurred getting user details", ex); } return(Json(response)); }
public ActionResult ValidateUsername(ViewModel.AccountRecoveryInfoViewModel accountInfo) { try { if (!ModelState.IsValid) { ModelState.AddModelError("Username", "Username is required"); _logger.Info("User submitted password reset form. But username does not exist in form value. Showing validation message."); return(View("~/Views/AccountRecovery/ResetPassword.cshtml", accountInfo)); } //Check user account disabled or not GenericAjaxResponse <AHP.Core.DTO.ExternalUserInfo> userResponse = _restClient.GetUserDetails(accountInfo.Username); if (!userResponse.Success || userResponse.Data == null) { ModelState.AddModelError("Username", "Account information does not exist"); return(View("~/Views/AccountRecovery/ResetPassword.cshtml", accountInfo)); } if (!userResponse.Data.IsActive) { ModelState.AddModelError("Username", "Your account has been disabled. Please contact your account manager."); return(View("~/Views/AccountRecovery/ResetPassword.cshtml", accountInfo)); } //Get security questions for the user. GenericAjaxResponse <List <AHP.Core.DTO.UserSecurityOption> > apiResponse = _restClient.GetSecurityQuestionsForUser(accountInfo.Username); //only two questions need to be present and user should also be present if (apiResponse.Success && apiResponse.Data != null && apiResponse.Data.Count == 3) { ViewModel.UserQuestionsViewmodel usrQuestionInfo = new ViewModel.UserQuestionsViewmodel() { SecurityQuestions = new List <string>() }; //Pre fill primary and secondary questions that the user had selected usrQuestionInfo.PrimarySelectedQuestion = apiResponse.Data[0].Question; usrQuestionInfo.SecondarySelectedQuestion = apiResponse.Data[1].Question; usrQuestionInfo.ThirdSelectedQuestion = apiResponse.Data[2].Question; ViewBag.Username = accountInfo.Username; _logger.Info("User details exists. Redirecting to answer security question page."); return(View("~/Views/AccountRecovery/AnswerSecurityQuestions.cshtml", usrQuestionInfo)); } else { ModelState.AddModelError(string.Empty, "Account information does not exist or you haven't setup your security questions in the system yet."); return(View("~/Views/AccountRecovery/ResetPassword.cshtml", accountInfo)); } } catch (Exception ex) { ModelState.AddModelError(string.Empty, "We are sorry. Could not process your request at this time."); _logger.Error("Error occurred validating username", ex); return(View("~/Views/AccountRecovery/ResetPassword.cshtml", accountInfo)); } }