示例#1
0
 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);
        }