Delegate session lifetime to actix-identity
crate
This commit is contained in:
@ -3,14 +3,10 @@
|
||||
use std::future::{Future, ready, Ready};
|
||||
use std::pin::Pin;
|
||||
use std::rc::Rc;
|
||||
|
||||
use actix_identity::RequestIdentity;
|
||||
|
||||
use actix_web::{dev::{forward_ready, Service, ServiceRequest, ServiceResponse, Transform}, Error, FromRequest, HttpMessage, HttpResponse};
|
||||
use actix_web::{dev::{forward_ready, Service, ServiceRequest, ServiceResponse, Transform}, Error, HttpResponse};
|
||||
use actix_web::body::EitherBody;
|
||||
use actix_web::cookie::{Cookie, CookieJar};
|
||||
use actix_web::http::header::http_percent_encode;
|
||||
|
||||
use crate::constants::SESSION_COOKIE_NAME;
|
||||
|
||||
// There are two steps in middleware processing.
|
||||
// 1. Middleware initialization, middleware factory gets called with
|
||||
@ -42,7 +38,7 @@ impl<S, B> Transform<S, ServiceRequest> for AuthMiddleware
|
||||
enum SessionStatus {
|
||||
SignedOut,
|
||||
RegularUser,
|
||||
Admin
|
||||
Admin,
|
||||
}
|
||||
|
||||
pub struct AuthInnerMiddleware<S> {
|
||||
@ -63,7 +59,7 @@ impl<S, B> Service<ServiceRequest> for AuthInnerMiddleware<S>
|
||||
|
||||
forward_ready!(service);
|
||||
|
||||
fn call(&self, mut req: ServiceRequest) -> Self::Future {
|
||||
fn call(&self, req: ServiceRequest) -> Self::Future {
|
||||
println!("Hi from start. You requested: {}", req.path());
|
||||
|
||||
let service = Rc::clone(&self.service);
|
||||
|
Reference in New Issue
Block a user