public async Task <IActionResult> Edit(string id, EditUserRequest model) { if (!ModelState.IsValid) { return(NotFoundView()); } Result editResult = await _manageUserService.EditUser(id, model, GetUserId()); Result <UserDetailsViewModel> userResult = _userDataService.GetDetailsViewModel(id); if (userResult.Failure) { return(NotFoundView()); } if (editResult.Failure) { ModelState.AddErrors(editResult.Errors); userResult.Value.StatusAlert = StatusAlertViewExtension.Get(editResult); return(View("Details", userResult.Value)); } userResult.Value.StatusAlert = StatusAlertViewExtension.Get("User updated"); return(View("Details", userResult.Value)); }
public IActionResult Details(string id, EditRoleRequest request) { if (!ModelState.IsValid) { return(NotFoundView()); } Result <RoleDetailViewModel> role = _roleDataService.GetDetails(id); if (role.Failure) { return(NotFoundView()); } Result editResult = _roleService.EditRole(id, request, GetUserId()); if (editResult.Failure) { ModelState.AddErrors(editResult.Errors); role.Value.StatusAlert = StatusAlertViewExtension.Get(editResult); return(View(role.Value)); } role.Value.StatusAlert = StatusAlertViewExtension.Get("Role updated"); return(View(role.Value)); }
public async Task <IActionResult> SendVerifyEmail(string id) { if (!ModelState.IsValid) { return(NotFoundView()); } Result result = await _manageUserService.SendEmilVerificationMail(new SendEmailVerificationMailRequest(id), GetUserId()); Result <UserDetailsViewModel> userResult = _userDataService.GetDetailsViewModel(id); if (userResult.Failure) { return(NotFoundView()); } if (result.Failure) { ModelState.AddErrors(result.Errors); userResult.Value.StatusAlert = StatusAlertViewExtension.Get(result); return(View("Details", userResult.Value)); } userResult.Value.StatusAlert = StatusAlertViewExtension.Get("Verify Email mail sent"); return(View("Details", userResult.Value)); }
public IActionResult Unlock(string id) { if (!ModelState.IsValid) { return(NotFoundView()); } Result result = _manageUserService.UnlockUser(new UnlockUserRequest(id), GetUserId()); Result <UserDetailsViewModel> userResult = _userDataService.GetDetailsViewModel(id); if (userResult.Failure) { return(NotFoundView()); } if (result.Failure) { ModelState.AddErrors(result.Errors); userResult.Value.StatusAlert = StatusAlertViewExtension.Get(result); return(View("Details", userResult.Value)); } userResult.Value.StatusAlert = StatusAlertViewExtension.Get("User unlocked"); return(View("Details", userResult.Value)); }
public IActionResult Edit(long id, EditEmailRequest editEmail) { if (!ModelState.IsValid) { return(NotFoundView()); } Result <EmailViewModel> role = _emailDataService.GetViewModel(id, GetUserId()); if (role.Failure) { return(NotFoundView()); } Result editResult = _manageEmailService.Edit(id, editEmail); if (editResult.Failure) { ModelState.AddErrors(editResult.Errors); role.Value.StatusAlert = StatusAlertViewExtension.Get(editResult); return(View("Details", role.Value)); } role.Value.StatusAlert = StatusAlertViewExtension.Get("Email updated"); return(View("Details", role.Value)); }
public IActionResult Details(string id, EditPermissionRequest request) { if (!ModelState.IsValid) { return(NotFoundView()); } Result <PermissionViewModel> role = _permissionDataService.GetViewModel(id); if (role.Failure) { return(NotFoundView()); } Result editResult = _permissionService.Edit(id, request); if (editResult.Failure) { ModelState.AddErrors(editResult.Errors); role.Value.StatusAlert = StatusAlertViewExtension.Get(editResult); return(View(role.Value)); } role.Value.StatusAlert = StatusAlertViewExtension.Get("Permission updated"); return(View(role.Value)); }
public async Task<IActionResult> ExternalLoginRegister(ExternalLoginRegisterRequest externalLoginRegisterRequest, string returnUrl) { returnUrl = returnUrl ?? Url.Content("~/"); Result<ExternalLoginRegisterViewModel> getViewModelResult = await _accountDataService.GetExternalLoginViewModel(returnUrl); if (getViewModelResult.Failure) { //HACK: change to support list of errors LoginViewModel loginViewModel = await _accountDataService.GetLoginViewModel(returnUrl, getViewModelResult.Errors.FirstOrDefault()?.Message); return View(nameof(Login), loginViewModel); } if (!ModelState.IsValid) { return View(getViewModelResult.Value); } Result result = await _addUserService.ExternalLoginRequest(externalLoginRegisterRequest); if(result.Failure) { getViewModelResult.Value.StatusAlert = StatusAlertViewExtension.Get(result); ModelState.AddErrors(result.Errors); return View(getViewModelResult.Value); } return RedirectToAction(nameof(RegisterSuccess)); }
public IActionResult Profile(EditProfileRequest request) { if (!ModelState.IsValid) { return(RedirectToAction(nameof(Profile))); } Result editResult = _manageUserService.EditUser(GetUserId(), request); Result <ProfileViewModel> getResult = _manageDataService.GetProfile(GetUserId()); if (getResult.Failure) { ModelState.AddErrors(getResult.Errors); return(View()); } if (editResult.Failure) { getResult.Value.StatusAlert = StatusAlertViewExtension.Get(editResult); ModelState.AddErrors(editResult.Errors); return(View()); } getResult.Value.StatusAlert = StatusAlertViewExtension.Get("Profile updated"); return(View(getResult.Value)); }
public async Task <IActionResult> AddTwoFactorAuthenticator() { Result <AddTwoFactorAuthenticatorViewModel> result = await _manageDataService.GetAddTwoFactorAuthenticatorViewModel(GetUserId(), GetSessionCode(), GetIp()); if (result.Failure) { result.Value.StatusAlert = StatusAlertViewExtension.Get(result); return(View(result.Value)); } return(View(result.Value)); }
public IActionResult TwoFactorAuthenticator() { Result <TwoFactorAuthenticatorViewModel> result = _manageDataService.GetTwoFactorAuthenticatorViewModel(GetUserId()); if (result.Failure) { result.Value.StatusAlert = StatusAlertViewExtension.Get(result); return(View(result.Value)); } return(View(result.Value)); }
public async Task <IActionResult> RemoveExternalProvider() { Result result = await _credentialsService.RemoveExternalLogin(); if (result.Failure) { SaveTempData(STATUS_ALERT_TEMP_DATA_KEY, StatusAlertViewExtension.Get(result)); } else { SaveTempData(STATUS_ALERT_TEMP_DATA_KEY, StatusAlertViewExtension.Get("External provider was removed")); } return(RedirectToAction(nameof(Index))); }
public async Task <IActionResult> SendTwoFactorEmailAuthentication() { Result result = await _twoFactorAuthService.GenerateAndSendEmailCode(GetUserId()); if (result.Failure) { SaveTempData(EMAIL_STATUS_ALERT_TEMP_DATA_KEY, StatusAlertViewExtension.Get(result)); } else { SaveTempData(EMAIL_STATUS_ALERT_TEMP_DATA_KEY, StatusAlertViewExtension.Get("Code was send.")); } return(RedirectToAction(nameof(AddTwoFactorEmailAuthentication))); }
public async Task <IActionResult> DisableTwoFactorAuthenticationPost() { Result result = await _twoFactorAuthService.Disable(GetUserId()); if (result.Failure) { SaveTempData(INDEX_STATUS_ALERT_TEMP_DATA_KEY, StatusAlertViewExtension.Get(result)); } else { SaveTempData(INDEX_STATUS_ALERT_TEMP_DATA_KEY, StatusAlertViewExtension.Get("Two factor authentication disabled.")); } return(RedirectToAction(nameof(Index))); }
public NewRoleViewModel GetNewRoleViewModel(Result result = null) { StatusAlertViewModel statusAlert = null; if (result != null) { statusAlert = StatusAlertViewExtension.Get(result); } NewRoleViewModel newRoleViewModel = new NewRoleViewModel( statusAlert: statusAlert, roleTypes: GetRoleTypesList()); return(newRoleViewModel); }
public async Task <IActionResult> New(NewUserRequest newUserRequest) { if (!ModelState.IsValid) { return(View()); } Result <string> result = await _addUserService.AddUser(newUserRequest, GetUserId()); if (result.Failure) { ModelState.AddErrors(result.Errors); return(View(new NewUserViewModel(StatusAlertViewExtension.Get(result)))); } return(RedirectToAction(nameof(Details), new { id = result.Value })); }
public async Task <IActionResult> ResetTwoFactorAuthenticatorPost() { TwoFactorAuthenticatorViewModel viewModel; Result result = await _twoFactorAuthService.Reset(GetUserId(), GetSessionCode(), GetIp()); if (result.Failure) { viewModel = new TwoFactorAuthenticatorViewModel(StatusAlertViewExtension.Get(result)); ModelState.AddErrors(result.Errors); return(View(viewModel)); } TwoFactorAuthenticatorViewModel twoFaViewModel = new TwoFactorAuthenticatorViewModel(StatusAlertViewExtension.Get("Two factor authentication reset.")); return(View("TwoFactorAuthenticator", twoFaViewModel)); }
public async Task <IActionResult> AddTwoFactorPhoneAuthentication(AddTwoFactorPhoneAuthenticationRequest request) { if (!ModelState.IsValid) { return(RedirectToAction(nameof(Index))); } Result <IEnumerable <string> > verifyResult = await _twoFactorAuthService.VerifyPhoneTwoFactorCode(GetUserId(), request); if (verifyResult.Failure) { SaveTempData(PHONE_STATUS_ALERT_TEMP_DATA_KEY, StatusAlertViewExtension.Get(verifyResult)); return(RedirectToAction(nameof(AddTwoFactorEmailAuthentication))); } SaveTempData(RECOVERY_CODES_KEY, verifyResult.Value); return(RedirectToAction(nameof(RecoveryCodesView))); }
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))); }
public async Task <IActionResult> Edit(string id, EditUserRequest model) { if (!ModelState.IsValid) { return(NotFoundView()); } Result editResult = await _manageUserService.EditUser(id, model, GetUserId()); if (editResult.Failure) { SaveTempData(TEMP_DATA_STATUS_ALERT_KEY, StatusAlertViewExtension.Get(editResult)); } else { SaveTempData(TEMP_DATA_STATUS_ALERT_KEY, StatusAlertViewExtension.Get("User updated")); } return(RedirectToAction(nameof(Details), new { id })); }
public IActionResult Unlock(string id) { if (!ModelState.IsValid) { return(NotFoundView()); } Result result = _manageUserService.UnlockUser(new UnlockUserRequest(id), GetUserId()); if (result.Failure) { SaveTempData(TEMP_DATA_STATUS_ALERT_KEY, StatusAlertViewExtension.Get(result)); } else { SaveTempData(TEMP_DATA_STATUS_ALERT_KEY, StatusAlertViewExtension.Get("User unlocked")); } return(RedirectToAction(nameof(Details), new { id })); }
public async Task <IActionResult> SendVerifyEmail(string id) { if (!ModelState.IsValid) { return(NotFoundView()); } Result result = await _manageUserService.SendEmilVerificationMail(new SendEmailVerificationMailRequest(id), GetUserId()); if (result.Failure) { SaveTempData(TEMP_DATA_STATUS_ALERT_KEY, StatusAlertViewExtension.Get(result)); } else { SaveTempData(TEMP_DATA_STATUS_ALERT_KEY, StatusAlertViewExtension.Get("Verify Email mail sent")); } return(RedirectToAction(nameof(Details), new { id })); }
public async Task <IActionResult> CreatePassword(CreatePasswordRequest createPassword) { if (!ModelState.IsValid) { return(RedirectToAction(nameof(Index))); } Result result = await _credentialsService.CreatePassword(createPassword); if (result.Failure) { SaveTempData(STATUS_ALERT_TEMP_DATA_KEY, StatusAlertViewExtension.Get(result)); } else { SaveTempData(STATUS_ALERT_TEMP_DATA_KEY, StatusAlertViewExtension.Get("Password was created")); } return(RedirectToAction(nameof(Index))); }
public IActionResult Index() { Result <TwoFactorAuthenticatorViewModel> result = _twoFactorAuthorizationDataService.GetTwoFactorAuthenticatorViewModel(); if (result.Failure) { return(View(new TwoFactorAuthenticatorViewModel(StatusAlertViewExtension.Get(result)))); } TwoFactorAuthenticatorViewModel twoFactorAuthenticatorViewModel = result.Value; StatusAlertViewModel statusAlert = GetTempData <StatusAlertViewModel>(INDEX_STATUS_ALERT_TEMP_DATA_KEY); if (statusAlert != null) { ModelState.AddErrors(statusAlert.ValidationErrors); twoFactorAuthenticatorViewModel.StatusAlert = statusAlert; } return(View(twoFactorAuthenticatorViewModel)); }
public async Task <IActionResult> AddTwoFactorAuthenticator() { Result <AddTwoFactorAuthenticatorViewModel> result = await _twoFactorAuthorizationDataService.GetAuthenticatorViewModel(); if (result.Failure) { SaveTempData(INDEX_STATUS_ALERT_TEMP_DATA_KEY, StatusAlertViewExtension.Get(result)); return(RedirectToAction(nameof(Index))); } AddTwoFactorAuthenticatorViewModel addTwoFactorAuthenticator = result.Value; StatusAlertViewModel statusAlert = GetTempData <StatusAlertViewModel>(AUTHENTICATOR_STATUS_ALERT_TEMP_DATA_KEY); if (statusAlert != null) { ModelState.AddErrors(statusAlert.ValidationErrors); addTwoFactorAuthenticator.StatusAlert = statusAlert; } return(View(addTwoFactorAuthenticator)); }
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)); }
public async Task <IActionResult> AddTwoFactorAuthenticator(AddTwoFactorAuthenticatorRequest request) { if (!ModelState.IsValid) { return(RedirectToAction(nameof(Index))); } string userId = GetUserId(); Result verifyResult = await _twoFactorAuthService.VerifyTwoFactorCode(userId, GetSessionCode(), GetIp(), request); if (verifyResult.Failure) { ModelState.AddErrors(verifyResult.Errors); Result <AddTwoFactorAuthenticatorViewModel> codeResult = await _manageDataService.GetAddTwoFactorAuthenticatorViewModel(userId, GetSessionCode(), GetIp()); if (codeResult.Failure) { ModelState.AddErrors(verifyResult.Errors); return(View()); } return(View(codeResult.Value)); } Result <TwoFactorAuthenticatorViewModel> result = _manageDataService.GetTwoFactorAuthenticatorViewModel(GetUserId()); if (result.Failure) { result.Value.StatusAlert = StatusAlertViewExtension.Get(result); return(View(result.Value)); } result.Value.StatusAlert = StatusAlertViewExtension.Get("Authenticator added."); return(View("TwoFactorAuthenticator", result.Value)); }
public async Task <IActionResult> AddTwoFactorEmailAuthentication() { Result <AddEmailTwoFactorAuthenticationViewModel> result = await _twoFactorAuthorizationDataService.GetEmailViewModel(); if (result.Failure) { SaveTempData(INDEX_STATUS_ALERT_TEMP_DATA_KEY, StatusAlertViewExtension.Get(result)); return(RedirectToAction(nameof(Index))); } AddEmailTwoFactorAuthenticationViewModel addEmailTwoFactorAuthenticationViewModel = new AddEmailTwoFactorAuthenticationViewModel(); StatusAlertViewModel statusAlert = GetTempData <StatusAlertViewModel>(EMAIL_STATUS_ALERT_TEMP_DATA_KEY); if (statusAlert != null) { ModelState.AddErrors(statusAlert.ValidationErrors); addEmailTwoFactorAuthenticationViewModel.StatusAlert = statusAlert; } Result sendMailResult = await _twoFactorAuthService.GenerateAndSendEmailCode(GetUserId()); return(View(addEmailTwoFactorAuthenticationViewModel)); }