Пример #1
0
    public async Task <IActionResult> OnPostRemoveLoginAsync(string loginProvider, string providerKey)
    {
        var user = await _userManager.GetUserAsync(User);

        if (user == null)
        {
            return(NotFound($"Unable to load user with ID 'user.Id'."));
        }

        var result = await _userManager.RemoveLoginAsync(user, loginProvider, providerKey);

        if (!result.Succeeded)
        {
            StatusMessage = "The external login was not removed.";
            return(RedirectToPage());
        }

        await _signInManager.RefreshSignInAsync(user);

        StatusMessage = "The external login was removed.";
        return(RedirectToPage());
    }