private async Task <ActionResult> DeleteAndCheckSuccess(User user) { DeleteAccountStatus accountDeleteStatus = await DeleteAccountService.DeleteAccountAsync(userToBeDeleted : user, userToExecuteTheDelete : user, orphanPackagePolicy : AccountDeletionOrphanPackagePolicy.UnlistOrphans); if (!accountDeleteStatus.Success) { TempData["RequestFailedMessage"] = Strings.AccountSelfDelete_Fail; return(RedirectToAction("DeleteRequest")); } OwinContext.Authentication.SignOut(); return(SafeRedirect(Url.Home(false))); }
public override async Task <ActionResult> RequestAccountDeletion(string accountName = null) { var account = GetAccount(accountName); var currentUser = GetCurrentUser(); if (account == null || ActionsRequiringPermissions.ManageAccount.CheckPermissions(GetCurrentUser(), account) != PermissionsCheckResult.Allowed) { return(new HttpNotFoundResult()); } var model = GetDeleteOrganizationViewModel(account); if (model.HasPackagesThatWillBeOrphaned) { TempData["ErrorMessage"] = "You cannot delete your organization unless you transfer ownership of all of its packages to another account."; return(RedirectToAction(nameof(DeleteRequest))); } if (model.HasAdditionalMembers) { TempData["ErrorMessage"] = "You cannot delete your organization unless you remove all other members."; return(RedirectToAction(nameof(DeleteRequest))); } var result = await DeleteAccountService.DeleteAccountAsync(account, currentUser); if (result.Success) { TempData["Message"] = $"Your organization, '{accountName}', was successfully deleted!"; return(RedirectToAction("Organizations", "Users")); } else { TempData["ErrorMessage"] = $"There was an issue deleting your organization '{accountName}'. Please contact support for assistance."; return(RedirectToAction(nameof(DeleteRequest))); } }
public override async Task <ActionResult> RequestAccountDeletion(string accountName = null) { var user = GetAccount(accountName); if (user == null || user.IsDeleted) { return(HttpNotFound()); } TelemetryService.TrackRequestForAccountDeletion(user); if (!user.Confirmed) { // Unconfirmed users can be deleted immediately without creating a support request. DeleteAccountStatus accountDeleteStatus = await DeleteAccountService.DeleteAccountAsync(userToBeDeleted : user, userToExecuteTheDelete : user, orphanPackagePolicy : AccountDeletionOrphanPackagePolicy.UnlistOrphans); if (!accountDeleteStatus.Success) { TempData["RequestFailedMessage"] = Strings.AccountSelfDelete_Fail; return(RedirectToAction("DeleteRequest")); } OwinContext.Authentication.SignOut(); return(SafeRedirect(Url.Home(false))); } var isSupportRequestCreated = await _supportRequestService.TryAddDeleteSupportRequestAsync(user); if (isSupportRequestCreated) { var emailMessage = new AccountDeleteNoticeMessage(MessageServiceConfiguration, user); await MessageService.SendMessageAsync(emailMessage); } else { TempData["RequestFailedMessage"] = Strings.AccountDelete_CreateSupportRequestFails; } return(RedirectToAction(nameof(DeleteRequest))); }
public virtual async Task <ActionResult> Delete(DeleteAccountAsAdminViewModel model) { var accountToDelete = UserService.FindByUsername(model.AccountName) as TUser; if (accountToDelete == null || accountToDelete.IsDeleted) { return(View("DeleteAccountStatus", new DeleteAccountStatus() { AccountName = model.AccountName, Description = $"Account {model.AccountName} not found.", Success = false })); } else { var admin = GetCurrentUser(); var status = await DeleteAccountService.DeleteAccountAsync( userToBeDeleted : accountToDelete, userToExecuteTheDelete : admin, orphanPackagePolicy : model.ShouldUnlist?AccountDeletionOrphanPackagePolicy.UnlistOrphans : AccountDeletionOrphanPackagePolicy.KeepOrphans); return(View("DeleteAccountStatus", status)); } }