You've already forked authentication-service
mirror of
https://github.com/matrix-org/matrix-authentication-service.git
synced 2025-11-23 11:02:35 +03:00
storage: wrap the postgres repository in a struct
This commit is contained in:
@@ -14,9 +14,8 @@
|
||||
|
||||
use axum_extra::extract::cookie::{Cookie, PrivateCookieJar};
|
||||
use mas_data_model::BrowserSession;
|
||||
use mas_storage::{user::BrowserSessionRepository, DatabaseError, Repository};
|
||||
use mas_storage::{user::BrowserSessionRepository, Repository};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use sqlx::PgConnection;
|
||||
use ulid::Ulid;
|
||||
|
||||
use crate::CookieExt;
|
||||
@@ -44,17 +43,17 @@ impl SessionInfo {
|
||||
}
|
||||
|
||||
/// Load the [`BrowserSession`] from database
|
||||
pub async fn load_session(
|
||||
pub async fn load_session<R: Repository>(
|
||||
&self,
|
||||
conn: &mut PgConnection,
|
||||
) -> Result<Option<BrowserSession>, DatabaseError> {
|
||||
repo: &mut R,
|
||||
) -> Result<Option<BrowserSession>, R::Error> {
|
||||
let session_id = if let Some(id) = self.current {
|
||||
id
|
||||
} else {
|
||||
return Ok(None);
|
||||
};
|
||||
|
||||
let maybe_session = conn
|
||||
let maybe_session = repo
|
||||
.browser_session()
|
||||
.lookup(session_id)
|
||||
.await?
|
||||
|
||||
Reference in New Issue
Block a user