addet templates
This commit is contained in:
parent
230943ba64
commit
70c3515d2e
278
Cargo.lock
generated
278
Cargo.lock
generated
@ -231,6 +231,7 @@ dependencies = [
|
||||
"log",
|
||||
"reqwest",
|
||||
"rocket",
|
||||
"rocket_dyn_templates",
|
||||
"serde",
|
||||
"toml",
|
||||
"url",
|
||||
@ -292,6 +293,12 @@ version = "0.1.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "383d29d513d8764dcdc42ea295d979eb99c3c9f00607b3692cf68a431f7dca72"
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "1.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "2.9.1"
|
||||
@ -544,6 +551,21 @@ dependencies = [
|
||||
"cfg-if",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-channel"
|
||||
version = "0.5.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "82b8f8f868b36967f9606790d1903570de9ceaf870a7bf9fbbd3016d636a2cb2"
|
||||
dependencies = [
|
||||
"crossbeam-utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-utils"
|
||||
version = "0.8.21"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28"
|
||||
|
||||
[[package]]
|
||||
name = "crunchy"
|
||||
version = "0.2.4"
|
||||
@ -713,7 +735,7 @@ version = "0.4.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b035a542cf7abf01f2e3c4d5a7acbaebfefe120ae4efc7bde3df98186e4b8af7"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"bitflags 2.9.1",
|
||||
"proc-macro2",
|
||||
"proc-macro2-diagnostics",
|
||||
"quote",
|
||||
@ -929,6 +951,18 @@ dependencies = [
|
||||
"version_check",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "filetime"
|
||||
version = "0.2.26"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bc0505cd1b6fa6580283f6bdf70a73fcf4aba1184038c90902b92b3dd0df63ed"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"libredox",
|
||||
"windows-sys 0.60.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "flate2"
|
||||
version = "1.1.2"
|
||||
@ -981,6 +1015,15 @@ dependencies = [
|
||||
"percent-encoding",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fsevent-sys"
|
||||
version = "4.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "76ee7a02da4d231650c7cea31349b889be2f45ddb3ef3032d2ec8185f6313fd2"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "futures"
|
||||
version = "0.3.31"
|
||||
@ -1190,6 +1233,20 @@ dependencies = [
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "handlebars"
|
||||
version = "4.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "faa67bab9ff362228eb3d00bd024a4965d8231bbb7921167f0cfa66c6626b225"
|
||||
dependencies = [
|
||||
"log",
|
||||
"pest",
|
||||
"pest_derive",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"thiserror 1.0.69",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hashbrown"
|
||||
version = "0.15.4"
|
||||
@ -1571,6 +1628,26 @@ version = "0.1.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c8fae54786f62fb2918dcfae3d568594e50eb9b5c25bf04371af6fe7516452fb"
|
||||
|
||||
[[package]]
|
||||
name = "inotify"
|
||||
version = "0.9.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f8069d3ec154eb856955c1c0fbffefbf5f3c40a104ec912d4797314c1801abff"
|
||||
dependencies = [
|
||||
"bitflags 1.3.2",
|
||||
"inotify-sys",
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "inotify-sys"
|
||||
version = "0.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e05c02b5e89bff3b946cedeca278abc628fe811e604f027c45a8aa3cf793d0eb"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "inout"
|
||||
version = "0.1.4"
|
||||
@ -1615,7 +1692,7 @@ version = "0.7.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b86e202f00093dcba4275d4636b93ef9dd75d025ae560d2521b45ea28ab49013"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"bitflags 2.9.1",
|
||||
"cfg-if",
|
||||
"libc",
|
||||
]
|
||||
@ -1669,6 +1746,26 @@ dependencies = [
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "kqueue"
|
||||
version = "1.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "eac30106d7dce88daf4a3fcb4879ea939476d5074a9b7ddd0fb97fa4bed5596a"
|
||||
dependencies = [
|
||||
"kqueue-sys",
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "kqueue-sys"
|
||||
version = "1.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ed9625ffda8729b85e45cf04090035ac368927b8cebc34898e7c120f52e4838b"
|
||||
dependencies = [
|
||||
"bitflags 1.3.2",
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lazy_static"
|
||||
version = "1.5.0"
|
||||
@ -1690,6 +1787,17 @@ version = "0.2.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f9fbbcab51052fe104eb5e5d351cf728d30a5be1fe14d9be8a3b097481fb97de"
|
||||
|
||||
[[package]]
|
||||
name = "libredox"
|
||||
version = "0.1.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "391290121bad3d37fbddad76d8f5d1c1c314cfc646d143d7e07a3086ddff0ce3"
|
||||
dependencies = [
|
||||
"bitflags 2.9.1",
|
||||
"libc",
|
||||
"redox_syscall",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libsqlite3-sys"
|
||||
version = "0.35.0"
|
||||
@ -1779,6 +1887,18 @@ dependencies = [
|
||||
"adler2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "mio"
|
||||
version = "0.8.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"log",
|
||||
"wasi 0.11.1+wasi-snapshot-preview1",
|
||||
"windows-sys 0.48.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "mio"
|
||||
version = "1.0.4"
|
||||
@ -1832,12 +1952,40 @@ version = "0.29.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "71e2746dc3a24dd78b3cfcb7be93368c6de9963d30f43a6a73998a9cf4b17b46"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"bitflags 2.9.1",
|
||||
"cfg-if",
|
||||
"cfg_aliases",
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "normpath"
|
||||
version = "1.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c8911957c4b1549ac0dc74e30db9c8b0e66ddcd6d7acc33098f4c63a64a6d7ed"
|
||||
dependencies = [
|
||||
"windows-sys 0.59.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "notify"
|
||||
version = "6.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6205bd8bb1e454ad2e27422015fb5e4f2bcc7e08fa8f27058670d208324a4d2d"
|
||||
dependencies = [
|
||||
"bitflags 2.9.1",
|
||||
"crossbeam-channel",
|
||||
"filetime",
|
||||
"fsevent-sys",
|
||||
"inotify",
|
||||
"kqueue",
|
||||
"libc",
|
||||
"log",
|
||||
"mio 0.8.11",
|
||||
"walkdir",
|
||||
"windows-sys 0.48.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nu-ansi-term"
|
||||
version = "0.46.0"
|
||||
@ -1955,7 +2103,7 @@ version = "0.10.73"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8505734d46c8ab1e19a1dce3aef597ad87dcb4c37e7188231769bd6bd51cebf8"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"bitflags 2.9.1",
|
||||
"cfg-if",
|
||||
"foreign-types",
|
||||
"libc",
|
||||
@ -2135,6 +2283,50 @@ version = "2.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e"
|
||||
|
||||
[[package]]
|
||||
name = "pest"
|
||||
version = "2.8.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1db05f56d34358a8b1066f67cbb203ee3e7ed2ba674a6263a1d5ec6db2204323"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
"thiserror 2.0.12",
|
||||
"ucd-trie",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pest_derive"
|
||||
version = "2.8.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bb056d9e8ea77922845ec74a1c4e8fb17e7c218cc4fc11a15c5d25e189aa40bc"
|
||||
dependencies = [
|
||||
"pest",
|
||||
"pest_generator",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pest_generator"
|
||||
version = "2.8.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "87e404e638f781eb3202dc82db6760c8ae8a1eeef7fb3fa8264b2ef280504966"
|
||||
dependencies = [
|
||||
"pest",
|
||||
"pest_meta",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pest_meta"
|
||||
version = "2.8.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "edd1101f170f5903fde0914f899bb503d9ff5271d7ba76bbb70bea63690cc0d5"
|
||||
dependencies = [
|
||||
"pest",
|
||||
"sha2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pin-project-lite"
|
||||
version = "0.2.16"
|
||||
@ -2316,11 +2508,11 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "redox_syscall"
|
||||
version = "0.5.13"
|
||||
version = "0.5.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0d04b7d0ee6b4a0207a0a7adb104d23ecb0b47d6beae7152d0fa34b692b29fd6"
|
||||
checksum = "5407465600fb0548f1442edf71dd20683c6ed326200ace4b1ef0763521bb3b77"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"bitflags 2.9.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -2505,6 +2697,19 @@ dependencies = [
|
||||
"version_check",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rocket_dyn_templates"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "04bfc006e547e4f72b760ab861f5943b688aed8a82c4977b5500c98f5d17dbfa"
|
||||
dependencies = [
|
||||
"handlebars",
|
||||
"normpath",
|
||||
"notify",
|
||||
"rocket",
|
||||
"walkdir",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rocket_http"
|
||||
version = "0.5.1"
|
||||
@ -2561,7 +2766,7 @@ checksum = "c4816b748109d26daa30e72d231a3a6e42f9e2fffe6c08cbfed63113db0ce884"
|
||||
dependencies = [
|
||||
"aes",
|
||||
"aes-gcm",
|
||||
"bitflags",
|
||||
"bitflags 2.9.1",
|
||||
"block-padding",
|
||||
"byteorder",
|
||||
"bytes",
|
||||
@ -2636,7 +2841,7 @@ version = "2.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3bb94393cafad0530145b8f626d8687f1ee1dedb93d7ba7740d6ae81868b13b5"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"bitflags 2.9.1",
|
||||
"bytes",
|
||||
"chrono",
|
||||
"flurry",
|
||||
@ -2680,7 +2885,7 @@ version = "1.0.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c71e83d6afe7ff64890ec6b71d6a69bb8a610ab78ce364b3352876bb4c801266"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"bitflags 2.9.1",
|
||||
"errno",
|
||||
"libc",
|
||||
"linux-raw-sys",
|
||||
@ -2741,6 +2946,15 @@ dependencies = [
|
||||
"cipher",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "same-file"
|
||||
version = "1.0.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502"
|
||||
dependencies = [
|
||||
"winapi-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "schannel"
|
||||
version = "0.1.27"
|
||||
@ -2793,7 +3007,7 @@ version = "2.11.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"bitflags 2.9.1",
|
||||
"core-foundation",
|
||||
"core-foundation-sys",
|
||||
"libc",
|
||||
@ -3071,7 +3285,7 @@ version = "0.6.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3c879d448e9d986b661742763247d3693ed13609438cf3d006f51f5368a5ba6b"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"bitflags 2.9.1",
|
||||
"core-foundation",
|
||||
"system-configuration-sys",
|
||||
]
|
||||
@ -3208,7 +3422,7 @@ dependencies = [
|
||||
"bytes",
|
||||
"io-uring",
|
||||
"libc",
|
||||
"mio",
|
||||
"mio 1.0.4",
|
||||
"pin-project-lite",
|
||||
"signal-hook-registry",
|
||||
"slab",
|
||||
@ -3334,7 +3548,7 @@ version = "0.6.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "adc82fd73de2a9722ac5da747f12383d2bfdb93591ee6c58486e0097890f05f2"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"bitflags 2.9.1",
|
||||
"bytes",
|
||||
"futures-util",
|
||||
"http 1.3.1",
|
||||
@ -3440,6 +3654,12 @@ dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ucd-trie"
|
||||
version = "0.1.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2896d95c02a80c6d6a5d6e953d479f5ddf2dfdb6a244441010e373ac0fb88971"
|
||||
|
||||
[[package]]
|
||||
name = "uncased"
|
||||
version = "0.9.10"
|
||||
@ -3519,6 +3739,16 @@ version = "0.9.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a"
|
||||
|
||||
[[package]]
|
||||
name = "walkdir"
|
||||
version = "2.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b"
|
||||
dependencies = [
|
||||
"same-file",
|
||||
"winapi-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "want"
|
||||
version = "0.3.1"
|
||||
@ -3640,6 +3870,15 @@ version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
||||
|
||||
[[package]]
|
||||
name = "winapi-util"
|
||||
version = "0.1.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0978bf7171b3d90bac376700cb56d606feb40f251a475a5d6634613564460b22"
|
||||
dependencies = [
|
||||
"windows-sys 0.60.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi-x86_64-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
@ -3789,6 +4028,15 @@ dependencies = [
|
||||
"windows-link",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.48.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9"
|
||||
dependencies = [
|
||||
"windows-targets 0.48.5",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.52.0"
|
||||
@ -4016,7 +4264,7 @@ version = "0.39.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6f42320e61fe2cfd34354ecb597f86f413484a798ba44a8ca1165c58d42da6c1"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"bitflags 2.9.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
name = "auto-decrypt"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
template_dir = "src/api/templates"
|
||||
|
||||
[dependencies]
|
||||
async-trait = "0.1.88"
|
||||
@ -15,4 +16,8 @@ diesel = { version = "2.2.0", features = ["sqlite", "returning_clauses_for_sqlit
|
||||
rocket = "0.5.1"
|
||||
url = "2"
|
||||
custom_error = "1.9.2"
|
||||
enum_dispatch = "0.3.13"
|
||||
enum_dispatch = "0.3.13"
|
||||
|
||||
[dependencies.rocket_dyn_templates]
|
||||
version = "0.1.0"
|
||||
features = ["minijinja"]
|
||||
@ -1,3 +1,3 @@
|
||||
-- This file should undo anything in `up.sql`
|
||||
DROP TABLE IF EXISTS providers_records;
|
||||
DROP TABLE IF EXISTS providers_records;
|
||||
DROP TABLE IF EXISTS beggars_records;
|
||||
@ -5,6 +5,7 @@ CREATE TABLE providers_records (
|
||||
request_time BIGINT UNSIGNED NOT NULL,
|
||||
auth_methode TEXT NOT NULL,
|
||||
expires_at BIGINT UNSIGNED,
|
||||
has_notifyed BOOLEAN DEFAULT FALSE NOT NULL,
|
||||
state TEXT NOT NULL,
|
||||
awnsered_at BIGINT UNSIGNED,
|
||||
awnsered_by TEXT
|
||||
|
||||
12
src/api/consent.rs
Normal file
12
src/api/consent.rs
Normal file
@ -0,0 +1,12 @@
|
||||
use rocket_dyn_templates::{Template, context};
|
||||
use crate::orm::DbConn;
|
||||
use rocket::State;
|
||||
|
||||
|
||||
#[get("/<consent_id>", rank = 1)]
|
||||
pub(crate) fn consent(consent_id: i32, db_conn: &State<DbConn>) -> Template {
|
||||
|
||||
Template::render("index", context! {
|
||||
service: db_conn.get_record(consent_id)
|
||||
})
|
||||
}
|
||||
@ -1,5 +1,6 @@
|
||||
mod guards;
|
||||
mod request;
|
||||
mod consent;
|
||||
|
||||
use crate::app_config::CONFIG;
|
||||
use crate::orm::DbConn;
|
||||
@ -63,8 +64,9 @@ pub(crate) async fn start_api() -> () {
|
||||
let _ = rocket::build()
|
||||
.manage(DbConn::establish_connection(&CONFIG.wait().db_file))
|
||||
.mount("/", routes![index])
|
||||
.register("/", catchers![default])
|
||||
.mount("/request", routes![request::request_handler])
|
||||
.mount("/consent", routes![request::consent])
|
||||
.register("/", catchers![default])
|
||||
.configure(rocket_config)
|
||||
.launch()
|
||||
.await;
|
||||
|
||||
@ -60,8 +60,9 @@ pub(super) async fn request_handler(guard: Result<APIProviderRequest<'_>, HttpRe
|
||||
|
||||
db_conn.add_provider_record(&ProviderRecord {
|
||||
service_name: guard.name.to_string(),
|
||||
expires_at: expires_at, // Convert to sql timestamp + add used auth methode to record in db
|
||||
expires_at: expires_at,
|
||||
auth_methode: auth_methode,
|
||||
has_notifyed: false,
|
||||
state: record_state,
|
||||
awnsered_by: None,
|
||||
});
|
||||
|
||||
0
src/api/templates/404.html.j2
Normal file
0
src/api/templates/404.html.j2
Normal file
17
src/api/templates/_consent_form.html.j2
Normal file
17
src/api/templates/_consent_form.html.j2
Normal file
@ -0,0 +1,17 @@
|
||||
|
||||
{% if service.auth_methode == "Password" %}
|
||||
<p>A passkey is required to decrypt the service.</p>
|
||||
<form action="/consent" method="POST">
|
||||
<input type="password" name="key" placeholder="Key"/>
|
||||
<input type="submit" value="reject">Reject</input>
|
||||
<input type="submit" value="accept">Accept</input>
|
||||
</form>
|
||||
{% elif service.auth_methode == "Confirmation" %}
|
||||
<form action="/consent" method="POST">
|
||||
<input type="submit" value="reject">Reject</input>
|
||||
<input type="submit" value="accept">Accept</input>
|
||||
</form>
|
||||
{% else %}
|
||||
<p>This request dose not require any type of consent.
|
||||
Or the consent methode is not implemented for WebUi.</p>
|
||||
{% endif %}
|
||||
5
src/api/templates/_consent_noinput.html.j2
Normal file
5
src/api/templates/_consent_noinput.html.j2
Normal file
@ -0,0 +1,5 @@
|
||||
|
||||
<div>
|
||||
<p>The Request has allready been processed and {{ service.state }}</p>
|
||||
<p>At: {{service.awnsered_at}}; By: {{service.awnsered_by}}</p>
|
||||
</div>
|
||||
22
src/api/templates/_message.html.j2
Normal file
22
src/api/templates/_message.html.j2
Normal file
@ -0,0 +1,22 @@
|
||||
{% set colors = {
|
||||
"warn": "bg-yellow-50 border-yellow-300 text-yellow-800",
|
||||
"danger": "bg-red-50 border-red-300 text-red-800",
|
||||
"success":"bg-green-50 border-green-300 text-green-800"
|
||||
} %}
|
||||
|
||||
{% set icon = {
|
||||
"warn": "⚠️",
|
||||
"danger": "❌",
|
||||
"success":"✅"
|
||||
} %}
|
||||
|
||||
<div class="rounded-md border p-4 flex items-center space-x-2 {{ colors.get(type, colors['warn']) }}">
|
||||
<span class="text-xl">{{ icon.get(type, icon['warn']) }}</span>
|
||||
<span class="font-medium">{{ message }}</span>
|
||||
</div>
|
||||
|
||||
{# Usage:
|
||||
{% include "_status_banner.j2" with context %}
|
||||
{# Pass your own vars if needed #}
|
||||
{% include "_status_banner.j2" with type="danger" message="An error occurred!" %}
|
||||
#}
|
||||
15
src/api/templates/base.html.j2
Normal file
15
src/api/templates/base.html.j2
Normal file
@ -0,0 +1,15 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<title>{% block title %}{% endblock %}</title>
|
||||
{% block styles %}
|
||||
<link rel="stylesheet" href="/static/css/main.css">
|
||||
{% endblock %}
|
||||
</head>
|
||||
<body>
|
||||
{% block content %}
|
||||
{% endblock %}
|
||||
</body>
|
||||
</html>
|
||||
22
src/api/templates/consent.html.j2
Normal file
22
src/api/templates/consent.html.j2
Normal file
@ -0,0 +1,22 @@
|
||||
{% extends "base.html" %}
|
||||
{% set _inputStates = ["Pending"] %}
|
||||
|
||||
<h1>Consent {{service.name}}</h1>
|
||||
<h3>Request Information:</h3>
|
||||
<ul>
|
||||
<li>Service name: {{service.name}}</li>
|
||||
<li>Requested at: {{service.reqest_time}}</li>
|
||||
<li>Auth methode: {{service.expires_at}}</li>
|
||||
<li>Service State: {{service.state}}</li>
|
||||
</ul>
|
||||
|
||||
|
||||
{% if message %}
|
||||
{% include "message.html.j2" with message %}
|
||||
{% endif %}
|
||||
|
||||
{% if service.state not in _inputStates %}
|
||||
{% include "_consent_form.html.j2" %}
|
||||
{% else %}
|
||||
{% include "_consent_noinput.html.j2" %}
|
||||
{% endif %}
|
||||
@ -31,4 +31,9 @@ impl DbConn {
|
||||
.execute(conn)
|
||||
.expect("Error saving new beggars record");
|
||||
}
|
||||
|
||||
pub(crate) fn get_record(&self, id: i32) -> Option<RecordStates> {
|
||||
let conn = &mut *self.0.lock().unwrap();
|
||||
record_states.find(id).get_result::<RecordState>(conn)
|
||||
}
|
||||
}
|
||||
@ -18,6 +18,7 @@ diesel::table! {
|
||||
request_time -> BigInt,
|
||||
auth_methode -> Text,
|
||||
expires_at -> Nullable<BigInt>,
|
||||
has_notifyed -> Bool,
|
||||
state -> Text,
|
||||
awnsered_at -> Nullable<BigInt>,
|
||||
awnsered_by -> Nullable<Text>,
|
||||
|
||||
@ -20,6 +20,7 @@ pub(crate) struct ProviderRecord{
|
||||
pub(crate) service_name: String,
|
||||
pub(crate) expires_at: Option<i64>, // Unix timestamp
|
||||
pub(crate) auth_methode: AuthMethod,
|
||||
pub(crate) has_notifyed: bool,
|
||||
pub(crate) state: RecordStates,
|
||||
pub(crate) awnsered_by: Option<String>,
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user