Skip to content

Commit aa66d7e

Browse files
committed
auth: Implement AuthCheck for all RequestPartsExt implementers
1 parent 7d28c52 commit aa66d7e

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/auth.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use crate::controllers;
2+
use crate::controllers::util::RequestPartsExt;
23
use crate::middleware::app::RequestApp;
34
use crate::middleware::log_request::CustomMetadataRequestExt;
45
use crate::middleware::session::RequestSession;
@@ -8,7 +9,7 @@ use crate::util::errors::{
89
account_locked, forbidden, internal, AppError, AppResult, InsecurelyGeneratedTokenRevoked,
910
};
1011
use chrono::Utc;
11-
use http::{header, Request};
12+
use http::header;
1213

1314
#[derive(Debug, Clone)]
1415
pub struct AuthCheck {
@@ -54,7 +55,7 @@ impl AuthCheck {
5455
}
5556
}
5657

57-
pub fn check<B>(&self, request: &Request<B>) -> AppResult<Authentication> {
58+
pub fn check<T: RequestPartsExt>(&self, request: &T) -> AppResult<Authentication> {
5859
let auth = authenticate_user(request)?;
5960

6061
if let Some(token) = auth.api_token() {
@@ -151,7 +152,7 @@ impl Authentication {
151152
}
152153
}
153154

154-
fn authenticate_user<B>(req: &Request<B>) -> AppResult<Authentication> {
155+
fn authenticate_user<T: RequestPartsExt>(req: &T) -> AppResult<Authentication> {
155156
controllers::util::verify_origin(req)?;
156157

157158
let conn = req.app().db_write()?;

0 commit comments

Comments
 (0)