use serde::{Deserialize, Serialize}; use std::fmt::Display; #[derive(Debug, Serialize, Deserialize)] pub struct Identity { pub id: String, pub user_id: String, pub identity_data: Option, pub provider: String, pub last_sign_in_at: String, pub created_at: String, pub updated_at: String, } #[derive(Serialize, Deserialize, Debug)] pub struct User { pub id: String, pub aud: String, pub role: String, pub email: String, pub email_confirmed_at: Option, pub invited_at: Option, pub phone: String, pub phone_confirmed_at: Option, pub confirmation_sent_at: Option, // For backward compatibility only. Use EmailConfirmedAt or PhoneConfirmedAt instead. pub confirmed_at: Option, pub recovery_sent_at: Option, pub new_email: Option, pub email_change_sent_at: Option, pub new_phone: Option, pub phone_change_sent_at: Option, pub reauthentication_sent_at: Option, pub last_sign_in_at: Option, pub app_metadata: serde_json::Value, pub user_metadata: serde_json::Value, pub factors: Option>, pub identities: Vec, pub created_at: String, pub updated_at: String, pub banned_until: Option, pub deleted_at: Option, } #[derive(Serialize, Deserialize, Debug)] pub struct Factor { pub id: String, pub created_at: String, pub updated_at: String, pub status: String, pub friendly_name: Option, pub factor_type: String, } #[derive(Serialize, Deserialize, Debug)] pub struct AccessTokenResponse { pub access_token: String, pub token_type: String, pub expires_in: i64, pub expires_at: Option, // older versions of GoTrue do not return this pub refresh_token: String, pub user: User, pub provider_access_token: Option, pub provider_refresh_token: Option, } #[derive(Serialize, Deserialize, Debug)] pub struct OAuthError { pub error: String, pub error_description: Option, } impl Display for OAuthError { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self.error_description { Some(ref desc) => write!(f, "{}: {}", self.error, desc), None => write!(f, "{}", self.error), } } } #[derive(Serialize, Deserialize, Debug)] pub struct GoTrueError { pub code: i64, pub msg: String, pub error_id: Option, } #[derive(Serialize, Deserialize, Debug)] pub struct GoTrueSettings { pub external: GoTrueProviderSettings, pub disable_signup: bool, pub mailer_autoconfirm: bool, pub phone_autoconfirm: bool, pub sms_provider: String, pub mfa_enabled: Option, // older versions of GoTrue do not return this pub saml_enabled: Option, // older versions of GoTrue do not return this } #[derive(Serialize, Deserialize, Debug)] pub struct GoTrueProviderSettings { pub apple: bool, pub azure: bool, pub bitbucket: bool, pub discord: bool, pub facebook: bool, pub figma: Option, // older versions of GoTrue do not return this pub github: bool, pub gitlab: bool, pub google: bool, pub keycloak: bool, pub kakao: Option, // older versions of GoTrue do not return this pub linkedin: bool, pub notion: bool, pub spotify: bool, pub slack: bool, pub workos: bool, pub twitch: bool, pub twitter: bool, pub email: bool, pub phone: bool, pub zoom: bool, }