mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-14 11:42:25 +00:00
refactor auth
This commit is contained in:
@@ -8,6 +8,7 @@ use crate::error::Error;
|
|||||||
|
|
||||||
use super::{AuthInfo, CheckAuthentication};
|
use super::{AuthInfo, CheckAuthentication};
|
||||||
|
|
||||||
|
#[derive(Clone)]
|
||||||
pub struct AuthInfoExtractor<A: CheckAuthentication> {
|
pub struct AuthInfoExtractor<A: CheckAuthentication> {
|
||||||
pub inner: AuthInfo,
|
pub inner: AuthInfo,
|
||||||
pub _provider_type: PhantomData<A>,
|
pub _provider_type: PhantomData<A>,
|
||||||
@@ -29,14 +30,11 @@ where
|
|||||||
type Error = Error;
|
type Error = Error;
|
||||||
type Future = Ready<Result<Self, Self::Error>>;
|
type Future = Ready<Result<Self, Self::Error>>;
|
||||||
|
|
||||||
fn extract(req: &HttpRequest) -> Self::Future {
|
fn from_request(req: &HttpRequest, _: &mut Payload) -> Self::Future {
|
||||||
let result = req.app_data::<Data<A>>().unwrap().validate(req);
|
let result = req.app_data::<Data<A>>().unwrap().validate(req);
|
||||||
ready(result.map(|auth_info| Self {
|
ready(result.map(|auth_info| Self {
|
||||||
inner: auth_info,
|
inner: auth_info,
|
||||||
_provider_type: PhantomData,
|
_provider_type: PhantomData,
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
fn from_request(req: &HttpRequest, _payload: &mut Payload) -> Self::Future {
|
|
||||||
Self::extract(req)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user