public ActionResult UnlinkLogin_Post(string provider) { using (var context = dataContextFactory.Create()) { var model = LinkAccountModel.ForUser(context, User.Identity); if (!model.AllowRemovingLogin) { Flash.Error( "The login could not be unlinked because it is the last login available for this account."); } else { var providerAccount = OAuthWebSecurity.GetAccountsFromUserName(User.Identity.Name) .Single(a => a.Provider.ToLower() == provider.ToLower()); if (OAuthWebSecurity.DeleteAccount(providerAccount.Provider, providerAccount.ProviderUserId)) { Flash.Success("Your " + provider + " login has been unlinked"); } else { Flash.Error("The account could not be unlinked."); } } } return(RedirectToAction("LinkAccount")); }
public ActionResult LinkAccount() { using (var context = dataContextFactory.Create()) { var model = LinkAccountModel.ForUser(context, User.Identity); return(View("LinkAccount", model)); } }