use async_session::{Result, Session, SessionStore};
use async_trait::async_trait;
use shared_svc::cache::{CacheKey, RedisManager, redis::AsyncCommands};
use sqlx::PgPool;
use tracing::{debug, instrument};
#[derive(Debug, Clone)]
pub struct AuthService {
cache: RedisManager,
database: PgPool,
}
impl AuthService {
pub fn new(cache: &RedisManager, database: &PgPool) -> Self {
Self {
cache: cache.clone(),
database: database.clone(),
}
}
}
#[async_trait]
impl SessionStore for AuthService {
#[doc = " Get a session from the storage backend."]
#[doc = ""]
#[doc = " The input is expected to be the value of an identifying"]
#[doc = " cookie. This will then be parsed by the session middleware"]
#[doc = " into a session if possible"]
#[instrument(skip(self))]
async fn load_session(&self, cookie_value: String) -> Result