public virtual async Task <IActionResult> RemoveExternalLogin(RemoveExternalLogin removeExternalLogin, CancellationToken cancellationToken = default) { await this.SecurityManager .RemoveExternalLoginAsync(removeExternalLogin, cancellationToken); return(this.Ok()); }
/// <summary> /// Removes the extenral login of a user. /// </summary> /// <param name="removeExternalLogin">The <see cref="RemoveExternalLogin"/>.</param> /// <param name="cancellationToken">The <see cref="CancellationToken"/>.</param> /// <returns>Void.</returns> public virtual async Task RemoveExternalLoginAsync(RemoveExternalLogin removeExternalLogin, CancellationToken cancellationToken = default) { if (removeExternalLogin == null) { throw new ArgumentNullException(nameof(removeExternalLogin)); } var user = await this.UserManager .FindByIdAsync(removeExternalLogin.UserId); if (user == null) { throw new NullReferenceException(nameof(user)); } var result = await this.UserManager .RemoveLoginAsync(user, removeExternalLogin.LoginProvider, removeExternalLogin.ProviderKey); if (result.Succeeded) { await this.SignInManager .RefreshSignInAsync(user); } }