use async_trait::async_trait;
use crate::error::Result;
#[derive(Debug, Clone)]
pub struct AuthUser {
pub id: i64,
pub email: String,
pub role: String,
}
#[derive(Debug, Clone)]
pub struct Session {
pub token: String,
pub user_id: i64,
pub expires_at: chrono::NaiveDateTime,
}
#[async_trait]
pub trait AuthProvider: Send + Sync {
async fn authenticate(&self, email: &str, password: &str) -> Result<AuthUser>;
async fn create_session(&self, user_id: i64) -> Result<Session>;
async fn validate_session(&self, token: &str) -> Result<Option<AuthUser>>;
async fn destroy_session(&self, token: &str) -> Result<()>;
async fn get_user(&self, user_id: i64) -> Result<Option<AuthUser>>;
}
#[async_trait]
pub trait SessionStore: Send + Sync {
async fn store(&self, session: &Session) -> Result<()>;
async fn get(&self, token: &str) -> Result<Option<Session>>;
async fn delete(&self, token: &str) -> Result<()>;
async fn cleanup_expired(&self) -> Result<usize>;
}