sylvia_iot_auth/models/
authorization_code.rsuse std::error::Error as StdError;
use async_trait::async_trait;
use chrono::{DateTime, Utc};
#[derive(Debug, PartialEq)]
pub struct AuthorizationCode {
pub code: String,
pub expires_at: DateTime<Utc>,
pub redirect_uri: String,
pub scope: Option<String>,
pub client_id: String,
pub user_id: String,
}
#[derive(Default)]
pub struct QueryCond<'a> {
pub code: Option<&'a str>,
pub client_id: Option<&'a str>,
pub user_id: Option<&'a str>,
}
#[async_trait]
pub trait AuthorizationCodeModel: Sync {
async fn init(&self) -> Result<(), Box<dyn StdError>>;
async fn get(
&self,
authorization_code: &str,
) -> Result<Option<AuthorizationCode>, Box<dyn StdError>>;
async fn add(&self, code: &AuthorizationCode) -> Result<(), Box<dyn StdError>>;
async fn del(&self, cond: &QueryCond) -> Result<(), Box<dyn StdError>>;
}
pub const EXPIRES: i64 = 30;