diff options
Diffstat (limited to 'server/src/routes/ui/account/mod.rs')
-rw-r--r-- | server/src/routes/ui/account/mod.rs | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/server/src/routes/ui/account/mod.rs b/server/src/routes/ui/account/mod.rs index 1d36cd8..c04e29a 100644 --- a/server/src/routes/ui/account/mod.rs +++ b/server/src/routes/ui/account/mod.rs @@ -11,7 +11,7 @@ use super::{error::MyError, layout::LayoutPage}; use crate::{ database::{Database, User}, routes::ui::{error::MyResult, home::rocket_uri_macro_r_home, layout::DynLayoutPage}, - CONF, + CONF, uri, }; use anyhow::anyhow; use argon2::{password_hash::Salt, Argon2, PasswordHasher}; @@ -22,7 +22,7 @@ use rocket::{ http::{Cookie, CookieJar}, post, response::Redirect, - uri, FromForm, State, + FromForm, State, }; use serde::{Deserialize, Serialize}; @@ -42,17 +42,19 @@ pub async fn r_account_register() -> DynLayoutPage<'static> { title: "Register".to_string(), content: markup::new! { form.account[method="POST", action=""] { - h1 { "Register for " @CONF.brand } + h1 { "Register" } - label[for="inp-invitation"] { "Invite Code: " } + label[for="inp-invitation"] { "Invite Code" } input[type="text", id="inp-invitation", name="invitation"]; br; - label[for="inp-username"] { "Username: " } + label[for="inp-username"] { "Username" } input[type="text", id="inp-username", name="username"]; br; - label[for="inp-password"] { "Password: " } + label[for="inp-password"] { "Password" } input[type="password", id="inp-password", name="password"]; br; input[type="submit", value="Register now!"]; + + p { "Already have an account? " a[href=uri!(r_account_login())] { "Login here" } } } }, ..Default::default() @@ -72,19 +74,20 @@ pub struct LoginForm { #[get("/account/login")] pub fn r_account_login() -> DynLayoutPage<'static> { LayoutPage { - title: "Log in".to_string(), + title: "Login".to_string(), content: markup::new! { form.account[method="POST", action=""] { - h1 { "Log in to your Account" } + h1 { "Login" } - label[for="inp-username"] { "Username: " } + label[for="inp-username"] { "Username" } input[type="text", id="inp-username", name="username"]; br; - label[for="inp-password"] { "Password: " } + label[for="inp-password"] { "Password" } input[type="password", id="inp-password", name="password"]; br; input[type="submit", value="Login"]; p { "While logged in, a cookie will be used to identify you." } + p { "Don't have an account yet? " a[href=uri!(r_account_register())] { "Register here" } } } }, ..Default::default() @@ -162,13 +165,13 @@ pub fn r_account_login_post( .finish(), ); - Ok(Redirect::found(uri!(r_home()))) + Ok(Redirect::found(rocket::uri!(r_home()))) } #[post("/account/logout")] pub fn r_account_logout_post(jar: &CookieJar) -> MyResult<Redirect> { jar.remove_private(Cookie::named("session")); - Ok(Redirect::found(uri!(r_home()))) + Ok(Redirect::found(rocket::uri!(r_home()))) } pub fn login_logic(database: &Database, username: &str, password: &str) -> MyResult<String> { |