Skip to content

Commit

Permalink
Shield Tower: Rename to session storage
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielleHuisman committed Dec 25, 2024
1 parent fd573b9 commit 724538b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
11 changes: 6 additions & 5 deletions packages/integrations/shield-tower/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use http::{Request, Response};
use shield::{Session, Shield};
use tower_service::Service;

use crate::session::TowerSession;
use crate::session::TowerSessionStorage;

#[derive(Clone)]
pub struct ShieldService<S> {
Expand Down Expand Up @@ -66,10 +66,11 @@ where
}
};

let session_storage = match TowerSession::load(session.clone(), session_key).await {
Ok(session_storage) => session_storage,
Err(_err) => return Ok(Self::internal_server_error()),
};
let session_storage =
match TowerSessionStorage::load(session.clone(), session_key).await {
Ok(session_storage) => session_storage,
Err(_err) => return Ok(Self::internal_server_error()),
};
let shield_session = Session::new(session_storage);

req.extensions_mut().insert(shield);
Expand Down
6 changes: 3 additions & 3 deletions packages/integrations/shield-tower/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ use shield::{SessionData, SessionError, SessionStorage};
use tower_sessions::Session;

#[derive(Clone, Debug)]
pub struct TowerSession {
pub struct TowerSessionStorage {
session: Session,
session_key: &'static str,
session_data: Arc<Mutex<SessionData>>,
}

impl TowerSession {
impl TowerSessionStorage {
pub async fn load(session: Session, session_key: &'static str) -> Result<Self, SessionError> {
let data = Self::load_data(&session, session_key).await?;

Expand All @@ -35,7 +35,7 @@ impl TowerSession {
}

#[async_trait]
impl SessionStorage for TowerSession {
impl SessionStorage for TowerSessionStorage {
fn data(&self) -> Arc<Mutex<SessionData>> {
self.session_data.clone()
}
Expand Down

0 comments on commit 724538b

Please sign in to comment.