designed the register/login pages

This commit is contained in:
Artemis 2025-01-24 21:44:28 +01:00
parent 9a63f1fe2c
commit 35f35e3a81
8 changed files with 107 additions and 10 deletions

View file

@ -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>* {

View file

@ -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 = "<form>")]
@ -31,7 +31,7 @@ pub async fn handle_login(
form: Form<Contextual<'_, AuthForm<'_>>>,
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>")]

View file

@ -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 = "<tag>")]
#[post("/register_tag", data = "<tag>")]
pub async fn handle_register(
mut db: DollTagsDb,
tag: Form<Contextual<'_, TagForm<'_>>>,
@ -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(

View file

@ -0,0 +1,29 @@
{% extends "base" %}
{% block title %}Log in - {% endblock title %}
{% block main %}
<form action="/profile" id="stray-form">
<h2>Log in</h2>
{% if failure %}
<p class="form-error">No account with this username / password combination.</p>
{% endif %}
<div class="fields raised">
<div>
<p class="heading"><label for="username">Enter your username</label></p>
<input type="text" id="username" name="username" maxlength="256" placeholder="Woofer!" required autofocus />
</div>
<div>
<p class="heading"><label for="password">Enter your password</label></p>
<input type="password" id="password" name="password" placeholder="Keep it secret" minlength="8" />
<p class="center note"><a href="/password_reset">I forgot my password</a></p>
</div>
</div>
<input type="checkbox" name="anti_bot" style="display: none">
<button type="submit" class="submit">Log in</button>
</form>
{% endblock main %}

View file

@ -0,0 +1,46 @@
{% extends "base" %}
{% block title %}Register a new account - {% endblock title %}
{% block main %}
<form action="/profile" id="stray-form">
<h2>Register a new account</h2>
{% if failure %}
<p class="form-error">No account with this username / password combination.</p>
{% endif %}
<div class="fields raised">
<div>
<p class="heading"><label for="username">Enter your username</label></p>
<input type="text" id="username" name="username" maxlength="256" placeholder="Woofer!" required autofocus />
</div>
<div>
<p class="heading"><label for="password">Enter your password (min. 8 characters)</label></p>
<input type="password" id="password" name="password" placeholder="Keep it secret" minlength="8" />
</div>
<div>
<p class="heading"><label for="email">Optionally, add a recovery e-mail</label></p>
<input type="email" name="email" id="email" placeholder="woof@example.com">
<p>
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.
</p>
</div>
</div>
<input type="checkbox" name="anti_bot" style="display: none">
<div class="fields dual-fields vcenter">
<div>
<label class="checkbox" for="inhuman">
<input type="checkbox" name="inhuman" id="inhuman" required>
I am not a human
</label>
</div>
<button type="submit" class="submit">Create your account</button>
</div>
</form>
{% endblock main %}

View file

@ -11,7 +11,7 @@
<h1><a href="/">Doll.Tags</a></h1>
<nav>
<p><a class="btn" href="/register">New tag</a></p>
<p><a class="btn" href="/register_tag">New tag</a></p>
</nav>
</header>

View file

@ -12,7 +12,7 @@
<input type="text" inputmode="numeric" pattern="\d{6}" id="ident" name="ident" size="6" placeholder="000000"
autofocus {% if ident %}value="{{ident}}" {% endif %} />
<label for="ident">Alternatively, enter the microchip ID (hexadecimal form), if available</label>
<label for="microchip_id">Alternatively, enter the microchip ID (hexadecimal form), if available</label>
<input type="text" pattern="(0x)?[a-fA-F0-9]+" id="microchip_id" name="microchip_id" placeholder="A hexadecimal ID"
{% if microchip_id %}value="{{microchip_id}}" {% endif %} />