コード例 #1
0
        protected async Task <User> GetCurrentUserAsync()
        {
            var id = _userManager.GetUserId(User);

            if (id == null)
            {
                return(await Task.FromResult <User>(null));
            }

            return(await _applicationDbContext.Users
                   .FirstOrDefaultAsync(e => e.Id.Equals(Guid.Parse(id))));
        }
コード例 #2
0
        public IActionResult LinkLogin(string provider)
        {
            // Request a redirect to the external login provider to link a login for the current user
            var redirectUrl = Url.Action("LinkLoginCallback", "Account");
            var properties  = _signInManager.ConfigureExternalAuthenticationProperties(provider, redirectUrl, _userManager.GetUserId(User));

            return(Challenge(properties, provider));
        }