public CoreServiceResponse AddProvider(string providerName, string clientId, string clientSecret) { try { ApplicationRegistration.Data.Application app = GetServerApplicationOrDie(); OAuthSettingsData data = new OAuthSettingsData() { ApplicationName = app.Name, ApplicationIdentifier = app.Cuid, ProviderName = providerName, ClientId = clientId, ClientSecret = clientSecret }; OAuthClientSettings settings = OAuthSettingsRepository.Save(data).CopyAs <OAuthClientSettings>(); return(new CoreServiceResponse { Success = true, Data = settings }); } catch (Exception ex) { return(new CoreServiceResponse { Success = false, Message = ex.Message }); } }
public CoreServiceResponse RemoveProvider(string providerName) { try { ApplicationRegistration.Data.Application app = GetServerApplicationOrDie(); OAuthSettingsData data = OAuthSettingsRepository.OneOAuthSettingsDataWhere(c => c.ApplicationIdentifier == app.Cuid && c.ApplicationName == app.Name && c.ProviderName == providerName); if (data != null) { bool success = OAuthSettingsRepository.Delete(data); if (!success) { throw OAuthSettingsRepository.LastException; } return(new CoreServiceResponse { Success = OAuthSettingsRepository.Delete(data) }); } throw new InvalidOperationException($"OAuthSettings not found: AppId={app.Cuid}, AppName={app.Name}, Provider={providerName}"); } catch (Exception ex) { return(new CoreServiceResponse { Success = false, Message = ex.Message }); } }
public static OAuthSettings FromData(OAuthSettingsData data) { OAuthSettings settings = null; if (_settingsTypeMap.ContainsKey(data.ProviderName)) { settings = _settingsTypeMap[data.ProviderName].Construct <OAuthSettings>(); settings.CopyProperties(data); } return(settings); }
public bool AddProvider(OAuthSettingsData settings) { throw new NotImplementedException(); }