public async Task <IActionResult> AddUser( Guid?siteId, Guid roleId, Guid userId) { var selectedSite = await _siteManager.GetSiteForDataOperations(siteId, true); var user = await _userManager.Fetch(selectedSite.Id, userId); if (user != null) { var role = await _roleManager.FindByIdAsync(roleId.ToString()); if ((role != null) && (role.SiteId == selectedSite.Id)) { await _roleManager.AddUserToRole(user, role); this.AlertSuccess(string.Format(_sr["{0} was successfully added to the role {1}."], user.DisplayName, role.RoleName), true); } } return(RedirectToAction("RoleMembers", new { siteId = selectedSite.Id, roleId })); }
public async Task <IActionResult> VerifyEmail(Guid userId) { var user = await userManager.Fetch(userManager.Site.Id, userId); if (user == null) { return(this.RedirectToSiteRoot(Site)); } if (user.EmailConfirmed) { return(this.RedirectToSiteRoot(Site)); } var code = await userManager.GenerateEmailConfirmationTokenAsync((SiteUser)user); var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id.ToString(), code = code }, protocol: HttpContext.Request.Scheme); emailSender.SendAccountConfirmationEmailAsync( Site, user.Email, sr["Confirm your account"], callbackUrl).Forget(); await ipAddressTracker.TackUserIpAddress(Site.Id, user.Id); return(RedirectToAction("EmailConfirmationRequired", new { userId = user.Id, didSend = true })); }
public async Task <IActionResult> VerifyEmail(Guid userGuid) { var user = await userManager.Fetch(userManager.Site.SiteId, userGuid); if (user == null) { return(Redirect("/")); } if (user.EmailConfirmed) { return(Redirect("/")); } var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = user.RegisterConfirmGuid.ToString() }, protocol: HttpContext.Request.Scheme); await emailSender.SendAccountConfirmationEmailAsync( Site, user.Email, "Confirm your account", callbackUrl); return(RedirectToAction("EmailConfirmationRequired", new { userGuid = user.Id, didSend = true })); }
public async Task <VerifyEmailInfo> GetEmailVerificationInfo(Guid userId) { IUserContext userContext = null; string token = null; var user = await userManager.Fetch(userManager.Site.Id, userId); if (user != null) { token = await userManager.GenerateEmailConfirmationTokenAsync((SiteUser)user); userContext = new UserContext(user); } return(new VerifyEmailInfo(userContext, token)); }
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)); }