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))