Пример #1
0
        public async Task <IActionResult> Index(ManageMessageId?message = null)
        {
            var user = await GetCurrentUserAsync();

            if (user == null)
            {
                return(View("Error"));
            }

            var model = new IndexViewModel
            {
                StatusMessage     = ProfileResource.FromManageMessage(_localizer, message),
                HasPassword       = await _userManager.HasPasswordAsync(user),
                PhoneNumber       = await _userManager.GetPhoneNumberAsync(user),
                TwoFactor         = await _userManager.GetTwoFactorEnabledAsync(user),
                Logins            = await _userManager.GetLoginsAsync(user),
                BrowserRemembered = await _signInManager.IsTwoFactorClientRememberedAsync(user)
            };

            return(View(model));
        }
Пример #2
0
        public async Task <IActionResult> ManageLogins(ManageMessageId?message = null)
        {
            var user = await GetCurrentUserAsync();

            if (user == null)
            {
                return(View("Error"));
            }

            var userLogins = await _userManager.GetLoginsAsync(user);

            var schemes = await _signInManager.GetExternalAuthenticationSchemesAsync();

            var otherLogins = schemes.Where(auth => userLogins.All(ul => auth.Name != ul.ProviderDisplayName)).ToList();

            ViewData["ShowRemoveButton"] = user.PasswordHash != null || userLogins.Count > 1;
            return(View(new ManageLoginsViewModel
            {
                StatusMessage = ProfileResource.FromManageMessage(_localizer, message),
                CurrentLogins = userLogins,
                OtherLogins = otherLogins
            }));
        }