From 916ac1009cd8f92b127afd3e15de061f39adf294 Mon Sep 17 00:00:00 2001 From: Emi Tatsuo Date: Sun, 22 Nov 2020 01:05:34 -0500 Subject: [PATCH] Add docs for add_um_routes --- src/user_management/routes.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/user_management/routes.rs b/src/user_management/routes.rs index e56c01f..6f66b6b 100644 --- a/src/user_management/routes.rs +++ b/src/user_management/routes.rs @@ -9,11 +9,30 @@ use crate::user_management::{User, RegisteredUser, UserManagerError}; const UNAUTH: &str = include_str!("pages/unauth.gmi"); const NSI: &str = include_str!("pages/nsi.gmi"); +/// Import this trait to use [`add_um_routes()`](Self::add_um_routes()) pub trait UserManagementRoutes: private::Sealed { + /// Add pre-configured routes to the serve to handle authentication + /// + /// Specifically, the following routes are added: + /// * `/account`, the main settings & login page + /// * `/account/askcert`, a page which always prompts for a certificate + /// * `/account/register`, for users to register a new account + /// * `/account/login`, for users to link their certificate to an existing account + /// * `/account/password`, to change the user's password + /// + /// If this method is used, no more routes should be added under `/account`. If you + /// would like to direct a user to login from your application, you should send them + /// to `/account`, which will start the login/registration flow. + /// + /// The `redir` argument allows you to specify the point that users will be directed + /// to return to once their account has been created. fn add_um_routes(self, redir: &'static str) -> Self; } impl UserManagementRoutes for crate::Builder { + /// Add pre-configured routes to the serve to handle authentication + /// + /// See [`UserManagementRoutes`] fn add_um_routes(self, redir: &'static str) -> Self { self.add_route("/account", move|r|handle_base::(r, redir)) .add_route("/account/askcert", move|r|handle_ask_cert::(r, redir))