public async Task <IActionResult> Index() { var user = await userManager.FindByIdAsync(HttpContext.User.GetUserId()); var model = new AccountIndexViewModel { HasPassword = (user.PasswordHash.Length > 0), PhoneNumber = user.PhoneNumber, TwoFactor = user.TwoFactorEnabled, Logins = await userManager.GetLoginsAsync(user), BrowserRemembered = await signInManager.IsTwoFactorClientRememberedAsync(user) }; return(View(model)); }
public async Task <IActionResult> Index() { var user = await userManager.FindByIdAsync(HttpContext.User.GetUserId()); var model = new AccountIndexViewModel { HasPassword = (user.PasswordHash.Length > 0), PhoneNumber = user.PhoneNumber.Length > 0 ? user.PhoneNumber : null, TwoFactor = user.TwoFactorEnabled, Logins = await userManager.GetLoginsAsync(user), BrowserRemembered = await signInManager.IsTwoFactorClientRememberedAsync(user), TimeZone = user.TimeZoneId }; if (string.IsNullOrEmpty(model.TimeZone)) { model.TimeZone = await timeZoneIdResolver.GetSiteTimeZoneId(); } return(View(model)); }
public async Task <ActionResult> UserActivity( Guid userId, Guid?siteId, int pageNumber = 1, int pageSize = 10 ) { if (userId == Guid.Empty) { return(RedirectToAction("Index")); } var selectedSite = await _siteManager.GetSiteForDataOperations(siteId); var user = await _userManager.Fetch(selectedSite.Id, userId); if (user == null) { return(RedirectToAction("Index")); } // only server admin site can edit other sites settings if (selectedSite.Id != _siteManager.CurrentSite.Id) { ViewData["Title"] = string.Format(CultureInfo.CurrentUICulture, _sr["{0} - User Activity - {1}"], selectedSite.SiteName, user.Email); } else { ViewData["Title"] = string.Format(CultureInfo.CurrentUICulture, _sr["User Activity - {0}"], user.Email); } var model = new UserActivityViewModel { SiteId = selectedSite.Id, UserId = user.Id, CreatedUtc = user.CreatedUtc, DisplayName = user.DisplayName, Email = user.Email, FirstName = user.FirstName, LastLoginUtc = user.LastLoginUtc, LastName = user.LastName, LastPassswordChangenUtc = user.LastPasswordChangeUtc, TimeZoneId = await _timeZoneIdResolver.GetUserTimeZoneId(), Locations = await _userManager.GetUserLocations( selectedSite.Id, userId, pageNumber, pageSize ), TwoFactor = user.TwoFactorEnabled, Logins = await _userManager.GetLoginsAsync(user as SiteUser) }; if (!string.IsNullOrWhiteSpace(user.TimeZoneId)) { model.UserTimeZone = user.TimeZoneId; } else { model.UserTimeZone = _userManager.Site.TimeZoneId; } var currentCrumbAdjuster = new NavigationNodeAdjuster(Request.HttpContext) { KeyToAdjust = "UserActivity", AdjustedText = string.Format(CultureInfo.CurrentUICulture, _sr["Activity - {0}"], user.Email), ViewFilterName = NamedNavigationFilters.Breadcrumbs // this is default but showing here for readers of code }; currentCrumbAdjuster.AddToContext(); return(View(model)); }