public async Task <ActionResult> Owner(string ownerId)
        {
            if (string.IsNullOrEmpty(ownerId))
            {
                return(RedirectToAction("Index", "Home"));
            }

            try
            {
                var ownerSettings = await _ownerSettingsStore.GetOwnerSettingsAsync(ownerId);

                var portalViewModel = new PortalViewModel(ownerSettings);

                // repos
                try
                {
                    var repos = await _repoSettingsStore.GetRepoSettingsForOwnerAsync(ownerId);

                    portalViewModel.RepoIds = repos.Select(r => r.RepositoryId).ToList();
                }
                catch (Exception e)
                {
                    Log.Error(e, "Error getting repositories for {0}", ownerId);
                }

                return(View("Index", portalViewModel));
            }
            catch (OwnerSettingsNotFoundException)
            {
                //redirect to a friendly warning page
                return(View("OwnerNotFound"));
            }
        }
Beispiel #2
0
        private async Task <List <RepoSettingsViewModel> > GetOwnerRepoSettings(string selectedOwnerId)
        {
            try
            {
                var repoSettings = await _repoSettingsStore.GetRepoSettingsForOwnerAsync(selectedOwnerId);

                var repoSettingsViewModels = repoSettings.Select(r => new RepoSettingsViewModel(r)).ToList();
                return(repoSettingsViewModels);
            }
            catch (RepoSettingsNotFoundException)
            {
                Log.Warning($"No repository settings found for '{selectedOwnerId}'");
                return(new List <RepoSettingsViewModel>());
            }
        }
        private async Task PopulateRepositoryList()
        {
            if (string.IsNullOrEmpty(DashboardMenuViewModel?.SelectedOwnerId))
            {
                return;
            }
            try
            {
                var repos = await _repoSettingsStore.GetRepoSettingsForOwnerAsync(this.DashboardMenuViewModel.SelectedOwnerId);

                foreach (var r in repos)
                {
                    var ri = new RepositoryInfo(r);
                    DashboardMenuViewModel.Owners.FirstOrDefault(o => o.OwnerId.Equals(this.DashboardMenuViewModel.SelectedOwnerId))?.Repositories.Add(ri);
                }
            }
            catch (RepoSettingsNotFoundException)
            {
                // do nothing
                return;
            }
        }
Beispiel #4
0
        public async Task <IActionResult> Delete(DeleteAccountViewModel davm)
        {
            try
            {
                if (!ModelState.IsValid || !davm.Confirm)
                {
                    ModelState.AddModelError("", "You must confirm that you want to delete your user account and associated settings.");
                    return(View("Delete"));
                }
                var deleted = await _userStore.DeleteUserAsync(User.Identity.Name);

                if (deleted)
                {
                    // delete user's settings
                    try
                    {
                        var us = await _userStore.GetUserSettingsAsync(User.Identity.Name);

                        await _userStore.DeleteUserSettingsAsync(User.Identity.Name);
                    }
                    catch (UserSettingsNotFoundException)
                    {
                        // no action needed
                    }
                    catch (UserStoreException e)
                    {
                        Log.Error($"Error deleting user settings during user account {User.Identity.Name} deletion", e);
                    }

                    // repositories
                    try
                    {
                        var repos = await _repoSettingsStore.GetRepoSettingsForOwnerAsync(User.Identity.Name);

                        foreach (var r in repos)
                        {
                            await _repoSettingsStore.DeleteRepoSettingsAsync(r.OwnerId, r.RepositoryId);
                        }
                    }
                    catch (RepoSettingsNotFoundException)
                    {
                        // no action needed
                    }
                    catch (RepoSettingsStoreException e)
                    {
                        Log.Error($"Error deleting repo settings during user account {User.Identity.Name} deletion", e);
                    }

                    // owner settings
                    try
                    {
                        var owner = await _ownerSettingsStore.GetOwnerSettingsAsync(User.Identity.Name);

                        await _ownerSettingsStore.DeleteOwnerSettingsAsync(owner.OwnerId);
                    }
                    catch (OwnerSettingsNotFoundException)
                    {
                        // no action needed
                    }
                    catch (OwnerSettingsStoreException e)
                    {
                        Log.Error($"Error deleting owner settings during user account {User.Identity.Name} deletion", e);
                    }

                    // datasets
                    try
                    {
                        await _datasetStore.DeleteDatasetsForOwnerAsync(User.Identity.Name);
                    }
                    catch (DatasetStoreException e)
                    {
                        Log.Error($"Error deleting datasets during user account {User.Identity.Name} deletion", e);
                    }

                    // templates
                    try
                    {
                        await _schemaStore.DeleteSchemaRecordsForOwnerAsync(User.Identity.Name);
                    }
                    catch (Exception e)
                    {
                        Log.Error($"Error deleting templates during user account {User.Identity.Name} deletion", e);
                    }

                    // jobs
                    try
                    {
                        await _jobStore.DeleteJobsForOwnerAsync(User.Identity.Name);
                    }
                    catch (Exception e)
                    {
                        Log.Error($"Error deleting jobs during user account {User.Identity.Name} deletion", e);
                    }


                    await HttpContext.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme);

                    return(RedirectToAction("Index", "Home"));
                }

                // error
                ViewBag.Message =
                    "Unable to delete account at this time, if the problem persists please open a ticket with support.";
                return(View("Delete"));
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }