From fbc1128f30438a4e18521073eb1bb79a77a7f20d Mon Sep 17 00:00:00 2001 From: metamuffin Date: Wed, 18 Jan 2023 21:49:11 +0100 Subject: first steps for registration --- server/src/routes/ui/account/mod.rs | 57 +++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 server/src/routes/ui/account/mod.rs (limited to 'server/src/routes/ui/account/mod.rs') diff --git a/server/src/routes/ui/account/mod.rs b/server/src/routes/ui/account/mod.rs new file mode 100644 index 0000000..86e0f18 --- /dev/null +++ b/server/src/routes/ui/account/mod.rs @@ -0,0 +1,57 @@ +use super::HtmlTemplate; +use rocket::form::Form; +use rocket::{get, post, FromForm}; + +#[derive(FromForm)] +pub struct RegisterForm { + #[field(validate = len(8..32))] + pub invitation: String, + #[field(validate = len(4..32))] + pub username: String, + #[field(validate = len(4..64))] + pub password: String, +} + +#[get("/account/register")] +pub fn r_account_register() -> HtmlTemplate> { + HtmlTemplate( + "Register".to_string(), + markup::new! { + h1 { "Register for Jellything" } + form[method="POST", action=""] { + label[for="inp-invitation"] { "Invite Code: " } + input[type="text", id="inp-invitation", name="invitation"]; br; + + label[for="inp-username"] { "Username: " } + input[type="text", id="inp-username", name="username"]; br; + label[for="inp-password"] { "Password: " } + input[type="password", id="inp-password", name="password"]; br; + + input[type="submit", value="Register now!"]; + } + }, + ) +} + +#[get("/account/login")] +pub fn r_account_login() -> HtmlTemplate> { + HtmlTemplate( + "Log in".to_string(), + markup::new! { + h1 { "Log in to your Account" } + + }, + ) +} + +#[post("/account/register", data = "
")] +pub fn r_account_register_post( + form: Form, +) -> HtmlTemplate> { + HtmlTemplate( + "Registration successful".to_string(), + markup::new! { + h1 { "Registration successful." } + }, + ) +} -- cgit v1.2.3-70-g09d2