mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-24 23:30:56 +00:00
Add skip_serialize_none to OAuth structs with option fields (#5046)
* Add skip_serialize_none to OAuth structs with option fields * PR feedback * Remove serde and ts export from SSO db-only structs
This commit is contained in:
parent
f6a24e133a
commit
33cbd95b7e
|
@ -19,11 +19,12 @@ pub struct CreateOAuthProvider {
|
||||||
pub client_id: String,
|
pub client_id: String,
|
||||||
pub client_secret: String,
|
pub client_secret: String,
|
||||||
pub scopes: String,
|
pub scopes: String,
|
||||||
pub auto_verify_email: bool,
|
pub auto_verify_email: Option<bool>,
|
||||||
pub account_linking_enabled: bool,
|
pub account_linking_enabled: Option<bool>,
|
||||||
pub enabled: bool,
|
pub enabled: Option<bool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[skip_serializing_none]
|
||||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||||
#[cfg_attr(feature = "full", derive(TS))]
|
#[cfg_attr(feature = "full", derive(TS))]
|
||||||
#[cfg_attr(feature = "full", ts(export))]
|
#[cfg_attr(feature = "full", ts(export))]
|
||||||
|
|
|
@ -87,39 +87,30 @@ impl Serialize for PublicOAuthProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
#[cfg_attr(feature = "full", derive(Insertable, AsChangeset, TS))]
|
#[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
|
||||||
#[cfg_attr(feature = "full", diesel(table_name = oauth_provider))]
|
#[cfg_attr(feature = "full", diesel(table_name = oauth_provider))]
|
||||||
#[cfg_attr(feature = "full", ts(export))]
|
|
||||||
pub struct OAuthProviderInsertForm {
|
pub struct OAuthProviderInsertForm {
|
||||||
pub display_name: String,
|
pub display_name: String,
|
||||||
#[cfg_attr(feature = "full", ts(type = "string"))]
|
|
||||||
pub issuer: DbUrl,
|
pub issuer: DbUrl,
|
||||||
#[cfg_attr(feature = "full", ts(type = "string"))]
|
|
||||||
pub authorization_endpoint: DbUrl,
|
pub authorization_endpoint: DbUrl,
|
||||||
#[cfg_attr(feature = "full", ts(type = "string"))]
|
|
||||||
pub token_endpoint: DbUrl,
|
pub token_endpoint: DbUrl,
|
||||||
#[cfg_attr(feature = "full", ts(type = "string"))]
|
|
||||||
pub userinfo_endpoint: DbUrl,
|
pub userinfo_endpoint: DbUrl,
|
||||||
pub id_claim: String,
|
pub id_claim: String,
|
||||||
pub client_id: String,
|
pub client_id: String,
|
||||||
pub client_secret: String,
|
pub client_secret: String,
|
||||||
pub scopes: String,
|
pub scopes: String,
|
||||||
pub auto_verify_email: bool,
|
pub auto_verify_email: Option<bool>,
|
||||||
pub account_linking_enabled: bool,
|
pub account_linking_enabled: Option<bool>,
|
||||||
pub enabled: bool,
|
pub enabled: Option<bool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
#[cfg_attr(feature = "full", derive(Insertable, AsChangeset, TS))]
|
#[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
|
||||||
#[cfg_attr(feature = "full", diesel(table_name = oauth_provider))]
|
#[cfg_attr(feature = "full", diesel(table_name = oauth_provider))]
|
||||||
#[cfg_attr(feature = "full", ts(export))]
|
|
||||||
pub struct OAuthProviderUpdateForm {
|
pub struct OAuthProviderUpdateForm {
|
||||||
pub display_name: Option<String>,
|
pub display_name: Option<String>,
|
||||||
#[cfg_attr(feature = "full", ts(type = "string"))]
|
|
||||||
pub authorization_endpoint: Option<DbUrl>,
|
pub authorization_endpoint: Option<DbUrl>,
|
||||||
#[cfg_attr(feature = "full", ts(type = "string"))]
|
|
||||||
pub token_endpoint: Option<DbUrl>,
|
pub token_endpoint: Option<DbUrl>,
|
||||||
#[cfg_attr(feature = "full", ts(type = "string"))]
|
|
||||||
pub userinfo_endpoint: Option<DbUrl>,
|
pub userinfo_endpoint: Option<DbUrl>,
|
||||||
pub id_claim: Option<String>,
|
pub id_claim: Option<String>,
|
||||||
pub client_secret: Option<String>,
|
pub client_secret: Option<String>,
|
||||||
|
|
|
@ -14,7 +14,7 @@ CREATE TABLE oauth_provider (
|
||||||
scopes text NOT NULL,
|
scopes text NOT NULL,
|
||||||
auto_verify_email boolean DEFAULT TRUE NOT NULL,
|
auto_verify_email boolean DEFAULT TRUE NOT NULL,
|
||||||
account_linking_enabled boolean DEFAULT FALSE NOT NULL,
|
account_linking_enabled boolean DEFAULT FALSE NOT NULL,
|
||||||
enabled boolean DEFAULT FALSE NOT NULL,
|
enabled boolean DEFAULT TRUE NOT NULL,
|
||||||
published timestamp with time zone DEFAULT now() NOT NULL,
|
published timestamp with time zone DEFAULT now() NOT NULL,
|
||||||
updated timestamp with time zone
|
updated timestamp with time zone
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue