diff --git a/migration.sql b/migration.sql index 8414ee0..1103353 100644 --- a/migration.sql +++ b/migration.sql @@ -67,7 +67,7 @@ CREATE TABLE IF NOT EXISTS "log" ( CREATE TABLE IF NOT EXISTS "location" ( "id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, - "name" text NOT NULL + "name" text NOT NULL UNIQUE ); CREATE TABLE IF NOT EXISTS "boat" ( @@ -85,7 +85,7 @@ CREATE TABLE IF NOT EXISTS "boat" ( CREATE TABLE IF NOT EXISTS "logbook_type" ( "id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, - "name" text NOT NULL -- e.g. 'Wanderfahrt', 'Regatta' + "name" text NOT NULL UNIQUE -- e.g. 'Wanderfahrt', 'Regatta' ); CREATE TABLE IF NOT EXISTS "logbook" ( diff --git a/src/tera/auth.rs b/src/tera/auth.rs index c622f15..0476940 100644 --- a/src/tera/auth.rs +++ b/src/tera/auth.rs @@ -18,14 +18,18 @@ use crate::model::{ user::{LoginError, User}, }; -#[get("/")] -fn index(flash: Option>) -> Template { +#[get("/?")] +fn index(flash: Option>, name: Option) -> Template { let mut context = tera::Context::new(); if let Some(msg) = flash { context.insert("flash", &msg.into_inner()); } + if let Some(n) = name { + context.insert("name", &n); + } + Template::render("auth/login", context.into_json()) } diff --git a/templates/auth/login.html.tera b/templates/auth/login.html.tera index 6c06f27..a099df4 100644 --- a/templates/auth/login.html.tera +++ b/templates/auth/login.html.tera @@ -14,7 +14,12 @@
- {{ macros::input(label='Name', name='name', type='input', required=true, class='rounded-t-md',hide_label=true) }} + {% if name %} + {{ macros::input(label='Name', name='name', type='input', required=true, class='rounded-t-md',hide_label=true,value=name) }} + {% else %} + {{ macros::input(label='Name', name='name', type='input', required=true, class='rounded-t-md',hide_label=true) }} + + {% endif %}
{{ macros::input(label='Passwort', name='password', type='password', class='rounded-b-md',hide_label=true) }}