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