20 lines
579 B
Rust
20 lines
579 B
Rust
|
// SPDX-FileCopyrightText: 2024 Simon Bruder <simon@sbruder.de>
|
||
|
//
|
||
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||
|
|
||
|
use actix_web::middleware::ErrorHandlerResponse;
|
||
|
use actix_web::{dev::ServiceResponse, error, HttpResponse};
|
||
|
|
||
|
pub fn redirect_to_login<B>(
|
||
|
res: ServiceResponse<B>,
|
||
|
) -> Result<ErrorHandlerResponse<B>, error::Error> {
|
||
|
Ok(ErrorHandlerResponse::Response(
|
||
|
res.into_response(
|
||
|
HttpResponse::SeeOther()
|
||
|
.insert_header(("Location", "/login"))
|
||
|
.finish()
|
||
|
.map_into_right_body(),
|
||
|
),
|
||
|
))
|
||
|
}
|