diff --git a/resources/migrations/sql/create_tables_001.sql b/resources/migrations/sql/create_tables_001.sql
index 1069eb3..0be5d6c 100644
--- a/resources/migrations/sql/create_tables_001.sql
+++ b/resources/migrations/sql/create_tables_001.sql
@@ -14,7 +14,7 @@ VALUES ('aaaabbbbccccddddeeeeffffgggghhhhiiiijjjjkkkk');
CREATE TABLE IF NOT EXISTS users
(
id INTEGER PRIMARY KEY AUTOINCREMENT,
- name TEXT NOT NULL,
+ name TEXT NOT NULL UNIQUE,
public_key TEXT NOT NULL,
creation_time DATETIME DEFAULT CURRENT_TIMESTAMP
);
diff --git a/resources/static/favicons/android-chrome-192x192.png b/resources/static/favicons/android-chrome-192x192.png
new file mode 100644
index 0000000..7a32768
Binary files /dev/null and b/resources/static/favicons/android-chrome-192x192.png differ
diff --git a/resources/static/favicons/android-chrome-512x512.png b/resources/static/favicons/android-chrome-512x512.png
new file mode 100644
index 0000000..bfde3bc
Binary files /dev/null and b/resources/static/favicons/android-chrome-512x512.png differ
diff --git a/resources/static/favicons/apple-touch-icon.png b/resources/static/favicons/apple-touch-icon.png
new file mode 100644
index 0000000..5f17456
Binary files /dev/null and b/resources/static/favicons/apple-touch-icon.png differ
diff --git a/resources/static/favicons/favicon-16x16.png b/resources/static/favicons/favicon-16x16.png
new file mode 100644
index 0000000..e46cf3a
Binary files /dev/null and b/resources/static/favicons/favicon-16x16.png differ
diff --git a/resources/static/favicons/favicon-32x32.png b/resources/static/favicons/favicon-32x32.png
new file mode 100644
index 0000000..47545b0
Binary files /dev/null and b/resources/static/favicons/favicon-32x32.png differ
diff --git a/resources/static/favicons/favicon.ico b/resources/static/favicons/favicon.ico
new file mode 100644
index 0000000..4b5a436
Binary files /dev/null and b/resources/static/favicons/favicon.ico differ
diff --git a/resources/static/favicons/site.webmanifest b/resources/static/favicons/site.webmanifest
new file mode 100644
index 0000000..bdcf016
--- /dev/null
+++ b/resources/static/favicons/site.webmanifest
@@ -0,0 +1,19 @@
+{
+ "name": "",
+ "short_name": "",
+ "icons": [
+ {
+ "src": "/static/favicons/android-chrome-192x192.png",
+ "sizes": "192x192",
+ "type": "image/png"
+ },
+ {
+ "src": "/static/favicons/android-chrome-512x512.png",
+ "sizes": "512x512",
+ "type": "image/png"
+ }
+ ],
+ "theme_color": "#ffffff",
+ "background_color": "#ffffff",
+ "display": "standalone"
+}
diff --git a/resources/templates/base.html b/resources/templates/base.html
index 410163c..f2eaf59 100644
--- a/resources/templates/base.html
+++ b/resources/templates/base.html
@@ -3,6 +3,12 @@
+
+
+
+
+
+
ledger
diff --git a/resources/templates/partials/index/failure.html b/resources/templates/partials/index/failure.html
new file mode 100644
index 0000000..58058c3
--- /dev/null
+++ b/resources/templates/partials/index/failure.html
@@ -0,0 +1,16 @@
+
+
+ Sorry mate, that was plainly wrong.
+
+
+
+
+
diff --git a/resources/templates/partials/index/form.html b/resources/templates/partials/index/form.html
index 31c2e32..d064ce9 100644
--- a/resources/templates/partials/index/form.html
+++ b/resources/templates/partials/index/form.html
@@ -4,8 +4,8 @@
hx-target="#home-page-main-block">
diff --git a/resources/templates/partials/index/success.html b/resources/templates/partials/index/success.html
index 6ec4fa7..c8d9768 100644
--- a/resources/templates/partials/index/success.html
+++ b/resources/templates/partials/index/success.html
@@ -1,7 +1,7 @@
- You are logged in as {{ name }}.
+ Congrat! You are now logged in as {{ user.name }}.
diff --git a/src/db/_users.rs b/src/db/_users.rs
index 1131f91..74af1bc 100644
--- a/src/db/_users.rs
+++ b/src/db/_users.rs
@@ -1,4 +1,4 @@
-use rusqlite::{params, Connection, Result, Row, Transaction};
+use rusqlite::{params, Connection, Result, Row, Transaction, OptionalExtension};
use serde::Serialize;
use crate::db::_external_id::{Id, UserId};
@@ -22,12 +22,12 @@ impl User {
}
pub fn create_user(tx: &Transaction, name: &String, public_key: &String) -> CustomResult
{
- tx.execute(
- "INSERT INTO users (name, public_key) VALUES (?1, ?2)",
+ tx.query_row(
+ "INSERT INTO users (name, public_key) VALUES (?1, ?2) RETURNING *",
(name, public_key),
+ _user_from_row
)
- .map_err(Error::SqlError)?;
- return get_user_by_id(tx, tx.last_insert_rowid() as i32);
+ .map_err(Error::SqlError)
}
fn _user_from_row(row: &Row) -> Result {
@@ -38,11 +38,21 @@ fn _user_from_row(row: &Row) -> Result {
})
}
-fn get_user_by_id(tx: &Transaction, id: i32) -> CustomResult {
+fn get_user_by_id(tx: &Transaction, id: & UserId) -> CustomResult