mirror of
https://github.com/mCaptcha/mCaptcha.git
synced 2026-02-13 19:15:39 +00:00
feat: migrate pages mod to use actix_auth_middleware
This commit is contained in:
@@ -25,6 +25,8 @@ pub fn services(cfg: &mut actix_web::web::ServiceConfig) {
|
||||
}
|
||||
|
||||
pub mod routes {
|
||||
use actix_auth_middleware::GetLoginRoute;
|
||||
|
||||
pub struct Auth {
|
||||
pub login: &'static str,
|
||||
pub join: &'static str,
|
||||
@@ -42,4 +44,18 @@ pub mod routes {
|
||||
[AUTH.login, AUTH.join]
|
||||
}
|
||||
}
|
||||
|
||||
impl GetLoginRoute for Auth {
|
||||
fn get_login_route(&self, src: Option<&str>) -> String {
|
||||
if let Some(redirect_to) = src {
|
||||
format!(
|
||||
"{}?redirect_to={}",
|
||||
self.login,
|
||||
urlencoding::encode(redirect_to)
|
||||
)
|
||||
} else {
|
||||
self.login.to_string()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user