diff options
author | metamuffin <metamuffin@disroot.org> | 2023-01-18 21:49:11 +0100 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2023-01-18 21:49:11 +0100 |
commit | fbc1128f30438a4e18521073eb1bb79a77a7f20d (patch) | |
tree | 94c0a41f6d3a4309944a05eb4aaff5ab2e3d24e4 /server/src/routes | |
parent | aaf7b47547e7dd43efb4da2f2790745521cd6eea (diff) | |
download | jellything-fbc1128f30438a4e18521073eb1bb79a77a7f20d.tar jellything-fbc1128f30438a4e18521073eb1bb79a77a7f20d.tar.bz2 jellything-fbc1128f30438a4e18521073eb1bb79a77a7f20d.tar.zst |
first steps for registration
Diffstat (limited to 'server/src/routes')
-rw-r--r-- | server/src/routes/mod.rs | 4 | ||||
-rw-r--r-- | server/src/routes/ui/account/mod.rs | 57 | ||||
-rw-r--r-- | server/src/routes/ui/mod.rs | 1 |
3 files changed, 62 insertions, 0 deletions
diff --git a/server/src/routes/mod.rs b/server/src/routes/mod.rs index 87d3051..f74ed65 100644 --- a/server/src/routes/mod.rs +++ b/server/src/routes/mod.rs @@ -1,6 +1,7 @@ use crate::AppState; use rocket::{catchers, routes, Build, Rocket}; use stream::r_stream; +use ui::account::{r_account_login, r_account_register, r_account_register_post}; use ui::error::r_not_found; use ui::home::r_home; use ui::node::r_library_node; @@ -23,6 +24,9 @@ pub fn build_rocket(state: AppState) -> Rocket<Build> { r_assets_font, r_stream, r_player, + r_account_login, + r_account_register, + r_account_register_post ], ) } 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<markup::DynRender<'static>> { + 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<markup::DynRender<'static>> { + HtmlTemplate( + "Log in".to_string(), + markup::new! { + h1 { "Log in to your Account" } + + }, + ) +} + +#[post("/account/register", data = "<form>")] +pub fn r_account_register_post( + form: Form<RegisterForm>, +) -> HtmlTemplate<markup::DynRender<'static>> { + HtmlTemplate( + "Registration successful".to_string(), + markup::new! { + h1 { "Registration successful." } + }, + ) +} diff --git a/server/src/routes/ui/mod.rs b/server/src/routes/ui/mod.rs index 1cad72c..8a3bc4e 100644 --- a/server/src/routes/ui/mod.rs +++ b/server/src/routes/ui/mod.rs @@ -13,6 +13,7 @@ pub mod layout; pub mod node; pub mod style; pub mod player; +pub mod account; pub struct HtmlTemplate<T>(pub String, pub T); |