public IHttpActionResult RemoveExternalLogin(string providerName, string providerUserId) { if (String.IsNullOrEmpty(providerName) || String.IsNullOrEmpty(providerUserId)) { return(BadRequest("Invalid Provider Name or Provider User Id.")); } if (ExceptionlessUser.OAuthAccounts.Count <= 1 && String.IsNullOrEmpty(ExceptionlessUser.Password)) { return(BadRequest("You must set a local password before removing your external login.")); } if (ExceptionlessUser.RemoveOAuthAccount(providerName, providerUserId)) { _userRepository.Save(ExceptionlessUser); } return(Ok()); }
public IHttpActionResult RemoveExternalLogin(string providerName, [NakedBody] string providerUserId) { if (String.IsNullOrEmpty(providerName) || String.IsNullOrEmpty(providerUserId)) { return(BadRequest("Invalid Provider Name or Provider User Id.")); } if (ExceptionlessUser.OAuthAccounts.Count <= 1 && String.IsNullOrEmpty(ExceptionlessUser.Password)) { return(BadRequest("You must set a local password before removing your external login.")); } if (ExceptionlessUser.RemoveOAuthAccount(providerName, providerUserId)) { _userRepository.Save(ExceptionlessUser); } ExceptionlessClient.Default.CreateFeatureUsage("Remove External Login").AddTags(providerName).AddObject(ExceptionlessUser).Submit(); return(Ok()); }
public async Task <IHttpActionResult> RemoveExternalLoginAsync(string providerName, [NakedBody] string providerUserId) { if (String.IsNullOrWhiteSpace(providerName) || String.IsNullOrWhiteSpace(providerUserId)) { _logger.Error().Message("Remove external login failed for \"{0}\": Invalid Provider Name or Provider User Id.", ExceptionlessUser.EmailAddress).Tag("External Login", providerName).Identity(ExceptionlessUser.EmailAddress).Property("User", ExceptionlessUser).Property("Provider User Id", providerUserId).SetActionContext(ActionContext).Write(); return(BadRequest("Invalid Provider Name or Provider User Id.")); } if (ExceptionlessUser.OAuthAccounts.Count <= 1 && String.IsNullOrEmpty(ExceptionlessUser.Password)) { _logger.Error().Message("Remove external login failed for \"{0}\": You must set a local password before removing your external login.", ExceptionlessUser.EmailAddress).Tag("External Login", providerName).Identity(ExceptionlessUser.EmailAddress).Property("User", ExceptionlessUser).Property("Provider User Id", providerUserId).SetActionContext(ActionContext).Write(); return(BadRequest("You must set a local password before removing your external login.")); } if (ExceptionlessUser.RemoveOAuthAccount(providerName, providerUserId)) { await _userRepository.SaveAsync(ExceptionlessUser, true); } _logger.Info().Message("\"{0}\" removed an external login: \"{1}\"", ExceptionlessUser.EmailAddress, providerName).Tag("External Login", providerName).Identity(ExceptionlessUser.EmailAddress).Property("User", ExceptionlessUser).SetActionContext(ActionContext).Write(); return(Ok()); }
public IHttpActionResult RemoveExternalLogin(string providerName, [NakedBody] string providerUserId) { if (String.IsNullOrEmpty(providerName) || String.IsNullOrEmpty(providerUserId)) { Log.Error().Message("Remove external login failed for \"{0}\": Invalid Provider Name or Provider User Id.", ExceptionlessUser.EmailAddress).Tag("External Login", providerName).Property("User", ExceptionlessUser).Property("Provider User Id", providerUserId).ContextProperty("HttpActionContext", ActionContext).Write(); return(BadRequest("Invalid Provider Name or Provider User Id.")); } if (ExceptionlessUser.OAuthAccounts.Count <= 1 && String.IsNullOrEmpty(ExceptionlessUser.Password)) { Log.Error().Message("Remove external login failed for \"{0}\": You must set a local password before removing your external login.", ExceptionlessUser.EmailAddress).Tag("External Login", providerName).Property("User", ExceptionlessUser).Property("Provider User Id", providerUserId).ContextProperty("HttpActionContext", ActionContext).Write(); return(BadRequest("You must set a local password before removing your external login.")); } if (ExceptionlessUser.RemoveOAuthAccount(providerName, providerUserId)) { _userRepository.Save(ExceptionlessUser); } Log.Info().Message("\"{0}\" removed an external login: \"{1}\"", ExceptionlessUser.EmailAddress, providerName).Tag("External Login", providerName).Property("User", ExceptionlessUser).ContextProperty("HttpActionContext", ActionContext).Write(); return(Ok()); }