23 lines
586 B
Rust
23 lines
586 B
Rust
use std::fmt::Display;
|
|
|
|
use actix_web::HttpResponse;
|
|
|
|
use crate::constants::LOGIN_ROUTE;
|
|
|
|
/// Create a redirect user response
|
|
pub fn redirect_user(uri: &str) -> HttpResponse {
|
|
HttpResponse::Found()
|
|
.append_header(("Location", uri))
|
|
.finish()
|
|
}
|
|
|
|
/// Redirect user to authenticate him
|
|
pub fn redirect_user_for_login<P: Display>(redirect_uri: P) -> HttpResponse {
|
|
HttpResponse::Found()
|
|
.append_header((
|
|
"Location",
|
|
format!("{}?redirect={}", LOGIN_ROUTE, urlencoding::encode(&redirect_uri.to_string()))
|
|
))
|
|
.finish()
|
|
}
|