diff options
Diffstat (limited to 'src/http/routes')
| -rw-r--r-- | src/http/routes/mod.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/http/routes/mod.rs b/src/http/routes/mod.rs index 1ef7fde..0ffecb0 100644 --- a/src/http/routes/mod.rs +++ b/src/http/routes/mod.rs @@ -43,7 +43,21 @@ pub(crate) fn logout(req: &Req) -> Res { res } +/// The router dispatches to it. The login tests drive a live listener, so they cannot move into the module. +/// +/// Module-internal in a production build, `pub` only under `test-support`: +/// one body behind two visibility declarations, exactly one of which compiles. +#[cfg(feature = "test-support")] pub fn login(state: &State, req: &Req) -> Res { + login_impl(state, req) +} + +#[cfg(not(feature = "test-support"))] +pub(crate) fn login(state: &State, req: &Req) -> Res { + login_impl(state, req) +} + +fn login_impl(state: &State, req: &Req) -> Res { let given = req.form_get("password").unwrap_or_default(); let page = Page::new("Sign in", csrf(state, req)); if auth::password_ok(&state.cfg, &given) { |
