mcaptcha/pages/auth/
mod.rs1pub mod login;
7pub mod register;
8pub mod sudo;
9
10pub fn services(cfg: &mut actix_web::web::ServiceConfig) {
11 cfg.service(login::login);
12 cfg.service(register::join);
13}
14
15pub mod routes {
16 use actix_auth_middleware::GetLoginRoute;
17
18 pub struct Auth {
19 pub login: &'static str,
20 pub join: &'static str,
21 }
22 impl Auth {
23 pub const fn new() -> Auth {
24 Auth {
25 login: "/login",
26 join: "/join",
27 }
28 }
29
30 pub const fn get_sitemap() -> [&'static str; 2] {
31 const AUTH: Auth = Auth::new();
32 [AUTH.login, AUTH.join]
33 }
34 }
35
36 impl GetLoginRoute for Auth {
37 fn get_login_route(&self, src: Option<&str>) -> String {
38 if let Some(redirect_to) = src {
39 format!(
40 "{}?redirect_to={}",
41 self.login,
42 urlencoding::encode(redirect_to)
43 )
44 } else {
45 self.login.to_string()
46 }
47 }
48 }
49}