BLOG-86 Checking authentication before uploading image #101
@ -32,7 +32,13 @@ pub async fn auth_middleware(
|
|||||||
next.call(req).await
|
next.call(req).await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct UserId(pub i32);
|
pub struct UserId(i32);
|
||||||
|
|
||||||
|
impl UserId {
|
||||||
|
pub fn get(&self) -> i32 {
|
||||||
|
self.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl FromRequest for UserId {
|
impl FromRequest for UserId {
|
||||||
type Error = Error;
|
type Error = Error;
|
||||||
|
@ -102,5 +102,5 @@ async fn logout_handler(session: Session) -> impl Responder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async fn get_logged_in_user_handler(user_id: UserId) -> impl Responder {
|
async fn get_logged_in_user_handler(user_id: UserId) -> impl Responder {
|
||||||
HttpResponse::Ok().body(format!("Logged in user ID: {}", user_id.0))
|
HttpResponse::Ok().body(format!("Logged in user ID: {}", user_id.get()))
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user