Beispiel #1
0
        private async Task <IActionResult> RouteToIndexPage(SiteUser user)
        {
            var model = new AccountIndexViewModel
            {
                HasPassword       = (!string.IsNullOrWhiteSpace(user.PasswordHash)),
                PhoneNumber       = !string.IsNullOrWhiteSpace(user.PhoneNumber) ? user.PhoneNumber : null,
                TwoFactor         = user.TwoFactorEnabled,
                Logins            = await UserManager.GetLoginsAsync(user),
                BrowserRemembered = await SignInManager.IsTwoFactorClientRememberedAsync(user),
                TimeZone          = user.TimeZoneId,
                Email             = user.Email
            };

            if (string.IsNullOrEmpty(model.TimeZone))
            {
                model.TimeZone = await TimeZoneIdResolver.GetSiteTimeZoneId();
            }

            return(View("Index", model));
        }
        public async Task <IActionResult> Index()
        {
            var user = await UserManager.FindByIdAsync(HttpContext.User.GetUserId());

            var model = new AccountIndexViewModel
            {
                HasPassword       = (!string.IsNullOrWhiteSpace(user.PasswordHash)),
                PhoneNumber       = !string.IsNullOrWhiteSpace(user.PhoneNumber) ? 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));
        }
Beispiel #3
0
        public virtual async Task <IActionResult> TimeZone()
        {
            var user = await UserManager.FindByIdAsync(HttpContext.User.GetUserId());

            var model = new TimeZoneViewModel
            {
                TimeZoneId = user.TimeZoneId
            };

            if (string.IsNullOrEmpty(model.TimeZoneId))
            {
                model.TimeZoneId = await TimeZoneIdResolver.GetSiteTimeZoneId();
            }
            model.AllTimeZones = TimeZoneHelper.GetTimeZoneList().Select(x =>
                                                                         new SelectListItem
            {
                Text     = x,
                Value    = x,
                Selected = model.TimeZoneId == x
            });

            return(View(model));
        }
        public virtual async Task <ActionResult> UserEdit(
            Guid userId,
            Guid?siteId
            )
        {
            if (userId == Guid.Empty)
            {
                return(RedirectToAction("Index"));
            }

            ViewData["ReturnUrl"] = Request.Path + Request.QueryString;
            var selectedSite = await SiteManager.GetSiteForDataOperations(siteId);

            // only server admin site can edit other sites settings
            if (selectedSite.Id != SiteManager.CurrentSite.Id)
            {
                ViewData["Title"] = string.Format(CultureInfo.CurrentUICulture, StringLocalizer["{0} - Manage User"], selectedSite.SiteName);
            }
            else
            {
                ViewData["Title"] = StringLocalizer["Manage User"];
            }



            var model = new EditUserViewModel
            {
                SiteId = selectedSite.Id
            };

            var user = await UserManager.Fetch(selectedSite.Id, userId);

            if (user != null)
            {
                model.UserId          = user.Id;
                model.Email           = user.Email;
                model.FirstName       = user.FirstName;
                model.LastName        = user.LastName;
                model.Username        = user.UserName;
                model.DisplayName     = user.DisplayName;
                model.AccountApproved = user.AccountApproved;
                model.Comment         = user.Comment;
                model.EmailConfirmed  = user.EmailConfirmed;
                model.IsLockedOut     = user.IsLockedOut;
                model.LastLoginDate   = user.LastLoginUtc;
                model.TimeZoneId      = user.TimeZoneId;
                model.WebSiteUrl      = user.WebSiteUrl;
                model.AvatarUrl       = user.AvatarUrl;

                if (string.IsNullOrEmpty(model.TimeZoneId))
                {
                    model.TimeZoneId = await TimeZoneIdResolver.GetSiteTimeZoneId();
                }
                model.AllTimeZones = TimeZoneHelper.GetTimeZoneList().Select(x =>
                                                                             new SelectListItem
                {
                    Text     = x,
                    Value    = x,
                    Selected = model.TimeZoneId == x
                });

                if (user.DateOfBirth > DateTime.MinValue)
                {
                    model.DateOfBirth = user.DateOfBirth;
                }

                model.UserClaims = await UserManager.GetClaimsAsync((SiteUser)user);

                model.UserRoles = await UserManager.GetRolesAsync((SiteUser)user);


                var currentCrumbAdjuster = new NavigationNodeAdjuster(Request.HttpContext)
                {
                    KeyToAdjust    = "UserEdit",
                    AdjustedText   = user.DisplayName,
                    ViewFilterName = NamedNavigationFilters.Breadcrumbs // this is default but showing here for readers of code
                };
                currentCrumbAdjuster.AddToContext();
            }

            var viewName = await CustomUserInfo.GetUserEditViewName(UserManager.Site, HttpContext);

            await CustomUserInfo.HandleUserEditGet(
                UserManager.Site,
                model,
                HttpContext,
                ViewData);

            return(View(viewName, model));
        }