From 35f35e3a817f21c0d4b4e0f8d9379010d8d1c294 Mon Sep 17 00:00:00 2001 From: Artemis Date: Fri, 24 Jan 2025 21:44:28 +0100 Subject: [PATCH] designed the register/login pages --- assets/site.css | 22 +++++++++ src/routes/form/accounts.rs | 6 +-- src/routes/form/register_tag.rs | 10 ++-- templates/account/login.html.tera | 29 ++++++++++++ templates/account/register.html.tera | 46 +++++++++++++++++++ templates/base.html.tera | 2 +- templates/index.html.tera | 2 +- ...ister.html.tera => register_tag.html.tera} | 0 8 files changed, 107 insertions(+), 10 deletions(-) create mode 100644 templates/account/login.html.tera create mode 100644 templates/account/register.html.tera rename templates/{register.html.tera => register_tag.html.tera} (100%) diff --git a/assets/site.css b/assets/site.css index c580f82..a197423 100644 --- a/assets/site.css +++ b/assets/site.css @@ -44,6 +44,10 @@ font-weight: bold; } +.center { + text-align: center; +} + picture.block { display: block; } @@ -69,6 +73,10 @@ h1>a { color: var(--clr-txt-on-dark); } +a { + color: var(--clr-error-primary-40); +} + input, select, button, @@ -107,6 +115,11 @@ textarea { font-size: 1em; } +input[type=checkbox], +label.checkbox { + display: inline-block; +} + header.padded, main { padding-left: 1em; @@ -132,6 +145,10 @@ div.form-error { padding: .5em 1em; } +p.note { + font-size: .8em; +} + .form-error>h4 { margin: 0; margin-top: .5em; @@ -162,6 +179,11 @@ p.field-error { div.dual-fields { display: flex; + width: 100%; +} + +.dual-fields.vcenter { + align-items: baseline; } .dual-fields>* { diff --git a/src/routes/form/accounts.rs b/src/routes/form/accounts.rs index ab58a55..a3fa57b 100644 --- a/src/routes/form/accounts.rs +++ b/src/routes/form/accounts.rs @@ -22,7 +22,7 @@ pub struct AuthForm<'a> { #[get("/login")] pub fn show_login() -> Template { - todo!("meow") + Template::render("account/login", context! {}) } #[post("/login", data = "
")] @@ -31,7 +31,7 @@ pub async fn handle_login( form: Form>>, cookies: &CookieJar<'_>, ) -> PageResult { - let miss = || PageResponse::Page(Template::render("login", context! {failure: true})); + let miss = || PageResponse::Page(Template::render("account/login", context! {failure: true})); let values = match &form.value { None => return Ok(miss()), @@ -58,7 +58,7 @@ pub async fn handle_login( #[get("/register")] pub fn show_register() -> Template { - todo!("meow") + Template::render("account/register", context! {}) } #[post("/register", data = "<_form>")] diff --git a/src/routes/form/register_tag.rs b/src/routes/form/register_tag.rs index f776430..4e5dbb7 100644 --- a/src/routes/form/register_tag.rs +++ b/src/routes/form/register_tag.rs @@ -14,12 +14,12 @@ use crate::{ routes::{error_handlers::PageResult, public}, }; -#[get("/register")] +#[get("/register_tag")] pub async fn show_register(db: DollTagsDb) -> PageResult { let ids = pick_ids(db).await?; Ok(Template::render( - "register", + "register_tag", context! { ids, previous: form::Context::default(), @@ -90,7 +90,7 @@ fn validate_chassis<'v>(a: &str, b: &str, c: &str, field: &str) -> form::Result< Ok(()) } -#[post("/register", data = "")] +#[post("/register_tag", data = "")] pub async fn handle_register( mut db: DollTagsDb, tag: Form>>, @@ -104,7 +104,7 @@ pub async fn handle_register( debug!("registration form invalid, context: {:?}", &tag.context); return Ok(Template::render( - "register", + "register_tag", context! { ids, previous: &tag.context, @@ -128,7 +128,7 @@ pub async fn handle_register( let microchip_id = normalize_opt(&normalized_microchip_id); if doll::id_exists(&mut *db, id, microchip_id.unwrap_or("")).await? { - return Ok(Redirect::found(uri!("/register")).into()); + return Ok(Redirect::found(uri!(show_register)).into()); } doll::create( diff --git a/templates/account/login.html.tera b/templates/account/login.html.tera new file mode 100644 index 0000000..f834ac0 --- /dev/null +++ b/templates/account/login.html.tera @@ -0,0 +1,29 @@ +{% extends "base" %} +{% block title %}Log in - {% endblock title %} +{% block main %} + +

Log in

+ + {% if failure %} +

No account with this username / password combination.

+ {% endif %} + +
+
+

+ +
+ +
+

+ +

I forgot my password

+
+ +
+ + + + + +{% endblock main %} \ No newline at end of file diff --git a/templates/account/register.html.tera b/templates/account/register.html.tera new file mode 100644 index 0000000..7810ce4 --- /dev/null +++ b/templates/account/register.html.tera @@ -0,0 +1,46 @@ +{% extends "base" %} +{% block title %}Register a new account - {% endblock title %} +{% block main %} +
+

Register a new account

+ + {% if failure %} +

No account with this username / password combination.

+ {% endif %} + +
+
+

+ +
+ +
+

+ +
+ +
+

+ +

+ This e-mail is fully optional and will only be used if you were to lose your password. + If you lose your password and haven't set an e-mail, you may still send me an e-mail and we'll see + together + to unblock you. +

+
+
+ + + +
+
+ +
+ +
+
+{% endblock main %} \ No newline at end of file diff --git a/templates/base.html.tera b/templates/base.html.tera index 22b3d92..4cdf0e0 100644 --- a/templates/base.html.tera +++ b/templates/base.html.tera @@ -11,7 +11,7 @@

Doll.Tags

diff --git a/templates/index.html.tera b/templates/index.html.tera index abccd9b..de42584 100644 --- a/templates/index.html.tera +++ b/templates/index.html.tera @@ -12,7 +12,7 @@ - + diff --git a/templates/register.html.tera b/templates/register_tag.html.tera similarity index 100% rename from templates/register.html.tera rename to templates/register_tag.html.tera