use sea_orm::entity::prelude::*; use time::OffsetDateTime; use uuid::Uuid; #[derive( Debug, Clone, Copy, PartialEq, Eq, EnumIter, DeriveActiveEnum, serde::Serialize, serde::Deserialize, )] #[serde(rename_all = "snake_case")] #[sea_orm(rs_type = "String", db_type = "String(StringLen::N(16))")] pub enum EmailVerificationPurpose { #[sea_orm(string_value = "signup")] Signup, #[sea_orm(string_value = "password_reset")] PasswordReset, #[sea_orm(string_value = "email_change")] EmailChange, } #[sea_orm::model] #[derive(Clone, Debug, PartialEq, DeriveEntityModel)] #[sea_orm(table_name = "user_email_verification_codes")] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] pub id: Uuid, pub user_id: Uuid, #[sea_orm(belongs_to, from = "user_id", to = "uid")] pub user: BelongsTo, pub email: String, pub purpose: EmailVerificationPurpose, #[sea_orm(unique)] pub token_hash: String, pub created_at: OffsetDateTime, pub expires_at: OffsetDateTime, pub used_at: Option, } impl ActiveModelBehavior for ActiveModel {}