private ActionResult AccountView(AccountViewModel model) { var user = GetCurrentUser(); model.CuratedFeeds = _curatedFeedService .GetFeedsForManager(user.Key) .Select(f => f.Name) .ToList(); model.CredentialGroups = GetCredentialGroups(user); model.SignInCredentialCount = model .CredentialGroups .Where(p => p.Key == CredentialKind.Password || p.Key == CredentialKind.External) .Sum(p => p.Value.Count); model.ExpirationInDaysForApiKeyV1 = _config.ExpirationInDaysForApiKeyV1; model.HasPassword = model.CredentialGroups.ContainsKey(CredentialKind.Password); model.CurrentEmailAddress = user.UnconfirmedEmailAddress ?? user.EmailAddress; model.HasConfirmedEmailAddress = !string.IsNullOrEmpty(user.EmailAddress); model.HasUnconfirmedEmailAddress = !string.IsNullOrEmpty(user.UnconfirmedEmailAddress); model.ChangePassword = model.ChangePassword ?? new ChangePasswordViewModel(); model.ChangePassword.EnablePasswordLogin = model.HasPassword; model.ChangeNotifications = model.ChangeNotifications ?? new ChangeNotificationsViewModel(); model.ChangeNotifications.EmailAllowed = user.EmailAllowed; model.ChangeNotifications.NotifyPackagePushed = user.NotifyPackagePushed; return(View("Account", model)); }
private ActionResult AccountView(AccountViewModel model) { // Load Credential info var user = GetCurrentUser(); var curatedFeeds = _curatedFeedService.GetFeedsForManager(user.Key); var creds = user.Credentials.Select(c => _authService.DescribeCredential(c)).ToList(); model.Credentials = creds; model.CuratedFeeds = curatedFeeds.Select(f => f.Name); model.ExpirationInDaysForApiKeyV1 = _config.ExpirationInDaysForApiKeyV1; return(View("Account", model)); }
private ActionResult AccountView(AccountViewModel model) { // Load user info var user = GetCurrentUser(); var curatedFeeds = _curatedFeedService.GetFeedsForManager(user.Key); var creds = user.Credentials.Where(c => CredentialTypes.IsSupportedCredential(c)) .Select(c => _authService.DescribeCredential(c)).ToList(); var packageNames = _packageService.FindPackageRegistrationsByOwner(user).Select(p => p.Id).ToList(); packageNames.Sort(); model.Credentials = creds; model.CuratedFeeds = curatedFeeds.Select(f => f.Name); model.Packages = packageNames; model.ExpirationInDaysForApiKeyV1 = _config.ExpirationInDaysForApiKeyV1; return(View("Account", model)); }
private ActionResult AccountView <TAccountViewModel>(TAccountViewModel model = null) where TAccountViewModel : AccountViewModel { model = model ?? Activator.CreateInstance <TAccountViewModel>(); // only users for now, but organizations are coming var userModel = model as UserAccountViewModel; if (userModel == null) { throw new ArgumentException("Invalid view model type.", nameof(model)); } // update model for all accounts var account = GetCurrentUser(); model.CuratedFeeds = _curatedFeedService .GetFeedsForManager(account.Key) .Select(f => f.Name) .ToList(); model.HasPassword = account.Credentials.Any(c => c.Type.StartsWith(CredentialTypes.Password.Prefix)); model.CurrentEmailAddress = account.UnconfirmedEmailAddress ?? account.EmailAddress; model.HasConfirmedEmailAddress = !string.IsNullOrEmpty(account.EmailAddress); model.HasUnconfirmedEmailAddress = !string.IsNullOrEmpty(account.UnconfirmedEmailAddress); model.ChangeEmail = new ChangeEmailViewModel(); model.ChangeNotifications = model.ChangeNotifications ?? new ChangeNotificationsViewModel(); model.ChangeNotifications.EmailAllowed = account.EmailAllowed; model.ChangeNotifications.NotifyPackagePushed = account.NotifyPackagePushed; // update model for user accounts UpdateUserAccountModel(account, userModel); return(View("Account", model)); }