Can redirect user on successful login

This commit is contained in:
2022-04-02 19:44:13 +02:00
parent da74acaed8
commit f08fddc79c
7 changed files with 46 additions and 10 deletions

View File

@ -9,8 +9,8 @@ use actix_web::{dev::{forward_ready, Service, ServiceRequest, ServiceResponse, T
use actix_web::body::EitherBody;
use askama::Template;
use crate::constants::{ADMIN_ROUTES, AUTHENTICATED_ROUTES, LOGIN_ROUTE};
use crate::controllers::base_controller::redirect_user;
use crate::constants::{ADMIN_ROUTES, AUTHENTICATED_ROUTES};
use crate::controllers::base_controller::redirect_user_for_login;
use crate::data::session_identity::{SessionIdentity, SessionIdentityData};
// There are two steps in middleware processing.
@ -100,7 +100,8 @@ impl<S, B> Service<ServiceRequest> for AuthInnerMiddleware<S>
// Redirect user to login page
if !identity.is_auth() && (req.path().starts_with(ADMIN_ROUTES) ||
req.path().starts_with(AUTHENTICATED_ROUTES)) {
return Ok(req.into_response(redirect_user(LOGIN_ROUTE))
let path = req.path().to_string();
return Ok(req.into_response(redirect_user_for_login(path))
.map_into_right_body());
}