feat: Type-erase Database backend for simpler code
This commit is contained in:
parent
9933990fd3
commit
ccbd97b836
17 changed files with 108 additions and 117 deletions
|
|
@ -6,7 +6,7 @@ use uuid::Uuid;
|
|||
|
||||
use std::sync::{Arc, RwLock};
|
||||
|
||||
use crate::db::{DatabaseInterface, User};
|
||||
use crate::db::User;
|
||||
use crate::http::HttpState;
|
||||
|
||||
pub const COOKIE_NAME: &str = "lldap_session";
|
||||
|
|
@ -83,12 +83,12 @@ impl PartialEq<HttpSession> for HttpSession {
|
|||
}
|
||||
}
|
||||
|
||||
impl<D: DatabaseInterface> FromRequestParts<HttpState<D>> for HttpSession {
|
||||
impl FromRequestParts<HttpState> for HttpSession {
|
||||
type Rejection = Redirect;
|
||||
|
||||
async fn from_request_parts(
|
||||
parts: &mut Parts,
|
||||
state: &HttpState<D>,
|
||||
state: &HttpState,
|
||||
) -> Result<Self, Self::Rejection> {
|
||||
let cookies = CookieJar::from_request_parts(parts, state).await.unwrap();
|
||||
state
|
||||
|
|
@ -108,12 +108,12 @@ impl std::ops::Deref for OptionalHttpSession {
|
|||
}
|
||||
}
|
||||
|
||||
impl<D: DatabaseInterface> OptionalFromRequestParts<HttpState<D>> for OptionalHttpSession {
|
||||
impl OptionalFromRequestParts<HttpState> for OptionalHttpSession {
|
||||
type Rejection = Redirect;
|
||||
|
||||
async fn from_request_parts(
|
||||
parts: &mut Parts,
|
||||
state: &HttpState<D>,
|
||||
state: &HttpState,
|
||||
) -> Result<Option<Self>, Self::Rejection> {
|
||||
let maybe_session = HttpSession::from_request_parts(parts, state)
|
||||
.await
|
||||
|
|
|
|||
Loading…
Reference in a new issue