use chrono::{DateTime, Utc}; use serde::{Deserialize, Serialize}; use sqlx::FromRow; use uuid::Uuid; use validator::Validate; #[derive(Debug, Serialize, Deserialize, FromRow, Clone)] pub struct User { pub id: Uuid, pub email: String, #[serde(skip)] pub encrypted_password: String, pub created_at: DateTime, pub updated_at: DateTime, pub last_sign_in_at: Option>, #[serde(rename = "app_metadata")] pub raw_app_meta_data: serde_json::Value, #[serde(rename = "user_metadata")] pub raw_user_meta_data: serde_json::Value, pub is_super_admin: Option, pub confirmed_at: Option>, pub email_confirmed_at: Option>, pub phone: Option, pub phone_confirmed_at: Option>, pub confirmation_token: Option, pub recovery_token: Option, pub email_change_token_new: Option, pub email_change: Option, pub deleted_at: Option>, } #[derive(Debug, Deserialize, Validate)] pub struct SignUpRequest { #[validate(email)] pub email: String, #[validate(length(min = 6, message = "Password must be at least 6 characters"))] pub password: String, pub data: Option, } #[derive(Debug, Deserialize, Validate)] pub struct SignInRequest { #[validate(email)] pub email: String, pub password: String, } #[derive(Debug, Serialize)] pub struct AuthResponse { pub access_token: String, pub token_type: String, pub expires_in: i64, pub refresh_token: String, pub user: User, } #[derive(Debug, Serialize, Deserialize, FromRow)] pub struct RefreshToken { pub id: i64, pub token: String, pub user_id: Uuid, pub revoked: bool, pub created_at: DateTime, pub updated_at: DateTime, pub parent: Option, pub session_id: Option, } #[derive(Debug, Deserialize, Validate)] pub struct RecoverRequest { #[validate(email)] pub email: String, } #[derive(Debug, Deserialize)] pub struct VerifyRequest { pub r#type: String, pub token: String, pub password: Option, } #[derive(Debug, Deserialize, Validate)] pub struct UserUpdateRequest { #[validate(email)] pub email: Option, #[validate(length(min = 6, message = "Password must be at least 6 characters"))] pub password: Option, pub data: Option, } #[derive(Debug, Serialize, Deserialize, FromRow)] pub struct MfaChallenge { pub id: Uuid, pub factor_id: Uuid, pub created_at: DateTime, pub verified_at: Option>, pub ip_address: Option, } #[derive(Debug, Serialize, Deserialize, Clone)] pub struct AmrEntry { pub method: String, pub timestamp: usize, }