add db constraints; add optional name for login (to be sent to members)

This commit is contained in:
philipp 2023-07-22 15:51:20 +02:00
parent 524d1acee2
commit 0381465272
3 changed files with 14 additions and 5 deletions

View File

@ -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" (

View File

@ -18,14 +18,18 @@ use crate::model::{
user::{LoginError, User},
};
#[get("/")]
fn index(flash: Option<FlashMessage<'_>>) -> Template {
#[get("/?<name>")]
fn index(flash: Option<FlashMessage<'_>>, name: Option<String>) -> 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())
}

View File

@ -14,7 +14,12 @@
<input type="hidden" name="remember" value="true">
<div class="-space-y-px rounded-md shadow-sm">
<div>
{{ 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 %}
</div>
<div>
{{ macros::input(label='Passwort', name='password', type='password', class='rounded-b-md',hide_label=true) }}