remove tera dependency and html rendering code.
This commit is contained in:
parent
dd113c3548
commit
06c2fd18bd
302
Cargo.lock
generated
302
Cargo.lock
generated
@ -109,7 +109,7 @@ dependencies = [
|
||||
"serde",
|
||||
"serde_json",
|
||||
"serde_urlencoded",
|
||||
"sha-1 0.9.6",
|
||||
"sha-1",
|
||||
"slab",
|
||||
"time 0.2.26",
|
||||
]
|
||||
@ -361,7 +361,7 @@ version = "0.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7fc95d1bdb8e6666b2b217308eeeb09f2d6728d104be3e31916cc74d15420331"
|
||||
dependencies = [
|
||||
"generic-array 0.14.4",
|
||||
"generic-array",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -396,7 +396,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "be14c7498ea50828a38d0e24a765ed2effe92a705885b57d029cd67d45744072"
|
||||
dependencies = [
|
||||
"cipher",
|
||||
"opaque-debug 0.3.0",
|
||||
"opaque-debug",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -406,7 +406,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ea2e11f5e94c2f7d386164cc2aa1f97823fed6f259e486940a71c174dd01b0ce"
|
||||
dependencies = [
|
||||
"cipher",
|
||||
"opaque-debug 0.3.0",
|
||||
"opaque-debug",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -455,9 +455,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "anyhow"
|
||||
version = "1.0.40"
|
||||
version = "1.0.41"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "28b2cd92db5cbd74e8e5028f7e27dd7aa3090e89e4f2a197cc7c8dfb69c7063b"
|
||||
checksum = "15af2628f6890fe2609a3b91bef4c83450512802e59489f9c1cb1fa5df064a61"
|
||||
|
||||
[[package]]
|
||||
name = "app"
|
||||
@ -659,34 +659,13 @@ dependencies = [
|
||||
"wyz",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "block-buffer"
|
||||
version = "0.7.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b"
|
||||
dependencies = [
|
||||
"block-padding",
|
||||
"byte-tools",
|
||||
"byteorder",
|
||||
"generic-array 0.12.4",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "block-buffer"
|
||||
version = "0.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4"
|
||||
dependencies = [
|
||||
"generic-array 0.14.4",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "block-padding"
|
||||
version = "0.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fa79dedbb091f449f1f39e53edf88d5dbe95f895dae6135a8d7b881fb5af73f5"
|
||||
dependencies = [
|
||||
"byte-tools",
|
||||
"generic-array",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -739,17 +718,11 @@ version = "3.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9c59e7af012c713f529e7a3ee57ce9b31ddd858d4b512923602f74608b009631"
|
||||
|
||||
[[package]]
|
||||
name = "byte-tools"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7"
|
||||
|
||||
[[package]]
|
||||
name = "bytemuck"
|
||||
version = "1.5.1"
|
||||
version = "1.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bed57e2090563b83ba8f83366628ce535a7584c9afa4c9fc0612a03925c6df58"
|
||||
checksum = "1bd24bfbd2c054630764222780a681282d7d524ffc28b7925e712afdfb3502bf"
|
||||
|
||||
[[package]]
|
||||
name = "byteorder"
|
||||
@ -850,23 +823,13 @@ dependencies = [
|
||||
"winapi 0.3.9",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "chrono-tz"
|
||||
version = "0.5.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2554a3155fec064362507487171dcc4edc3df60cb10f3a1fb10ed8094822b120"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"parse-zoneinfo",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cipher"
|
||||
version = "0.2.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "12f8e7987cbd042a63249497f41aed09f8e65add917ea6566effbc56578d6801"
|
||||
dependencies = [
|
||||
"generic-array 0.14.4",
|
||||
"generic-array",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -1080,7 +1043,7 @@ version = "0.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4857fd85a0c34b3c3297875b747c1e02e06b6a0ea32dd892d8192b9ce0813ea6"
|
||||
dependencies = [
|
||||
"generic-array 0.14.4",
|
||||
"generic-array",
|
||||
"subtle",
|
||||
]
|
||||
|
||||
@ -1124,28 +1087,13 @@ dependencies = [
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "deunicode"
|
||||
version = "0.4.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "850878694b7933ca4c9569d30a34b55031b9b139ee1fc7b94a527c4ef960d690"
|
||||
|
||||
[[package]]
|
||||
name = "digest"
|
||||
version = "0.8.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5"
|
||||
dependencies = [
|
||||
"generic-array 0.12.4",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "digest"
|
||||
version = "0.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066"
|
||||
dependencies = [
|
||||
"generic-array 0.14.4",
|
||||
"generic-array",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -1258,12 +1206,6 @@ dependencies = [
|
||||
"synstructure",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fake-simd"
|
||||
version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed"
|
||||
|
||||
[[package]]
|
||||
name = "flate2"
|
||||
version = "1.0.20"
|
||||
@ -1387,15 +1329,14 @@ dependencies = [
|
||||
"once_cell",
|
||||
"serde_json",
|
||||
"snafu",
|
||||
"tera",
|
||||
"unic-langid",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "flume"
|
||||
version = "0.10.5"
|
||||
version = "0.10.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fa9d66b91e902db43baefd8e40c8678ce29db2cf1d88ebd715174368d5fe70a9"
|
||||
checksum = "ddad16e8529759736a9ce4cdf078ed702e45d3c5b0474a1c65f5149e9fa7f1eb"
|
||||
dependencies = [
|
||||
"futures-core",
|
||||
"futures-sink",
|
||||
@ -1582,15 +1523,6 @@ dependencies = [
|
||||
"byteorder",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "generic-array"
|
||||
version = "0.12.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ffdf9f34f1447443d37393cc6c2b8313aebddcd96906caf34e54c68d8e57d7bd"
|
||||
dependencies = [
|
||||
"typenum",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "generic-array"
|
||||
version = "0.14.4"
|
||||
@ -1652,7 +1584,7 @@ version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "97304e4cd182c3846f7575ced3890c53012ce534ad9114046b0a9e00bb30a375"
|
||||
dependencies = [
|
||||
"opaque-debug 0.3.0",
|
||||
"opaque-debug",
|
||||
"polyval",
|
||||
]
|
||||
|
||||
@ -1691,17 +1623,6 @@ dependencies = [
|
||||
"regex",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "globwalk"
|
||||
version = "0.8.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "93e3af942408868f6934a7b85134a3230832b9977cf66125df2f9edcfce4ddcc"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"ignore",
|
||||
"walkdir",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gloo-events"
|
||||
version = "0.1.1"
|
||||
@ -1835,7 +1756,7 @@ version = "0.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "51ab2f639c231793c5f6114bdb9bbe50a7dbbfcd7c7c6bd8475dec2d991e964f"
|
||||
dependencies = [
|
||||
"digest 0.9.0",
|
||||
"digest",
|
||||
"hmac",
|
||||
]
|
||||
|
||||
@ -1846,7 +1767,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c1441c6b1e930e2817404b5046f1f989899143a12bf92de603b69f4e0aee1e15"
|
||||
dependencies = [
|
||||
"crypto-mac",
|
||||
"digest 0.9.0",
|
||||
"digest",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -1894,12 +1815,6 @@ version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6456b8a6c8f33fee7d958fcd1b60d55b11940a79e63ae87013e6d22e26034440"
|
||||
|
||||
[[package]]
|
||||
name = "humansize"
|
||||
version = "1.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "02296996cb8796d7c6e3bc2d9211b7802812d36999a51bb754123ead7d37d026"
|
||||
|
||||
[[package]]
|
||||
name = "humantime"
|
||||
version = "1.3.0"
|
||||
@ -1911,9 +1826,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "hyper"
|
||||
version = "0.14.8"
|
||||
version = "0.14.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d3f71a7eea53a3f8257a7b4795373ff886397178cd634430ea94e12d7fe4fe34"
|
||||
checksum = "07d6baa1b441335f3ce5098ac421fb6547c46dda735ca1bc6d0153c838f9dd83"
|
||||
dependencies = [
|
||||
"bytes 1.0.1",
|
||||
"futures-channel",
|
||||
@ -1925,7 +1840,7 @@ dependencies = [
|
||||
"httparse",
|
||||
"httpdate",
|
||||
"itoa",
|
||||
"pin-project 1.0.7",
|
||||
"pin-project-lite 0.2.6",
|
||||
"socket2 0.4.0",
|
||||
"tokio 1.6.1",
|
||||
"tower-service",
|
||||
@ -2136,9 +2051,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.95"
|
||||
version = "0.2.96"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "789da6d93f1b866ffe175afc5322a4d76c038605a1c3319bb57b06967ca98a36"
|
||||
checksum = "5600b4e6efc5421841a2138a6b082e07fe12f9aaa12783d50e5d13325b26b4fc"
|
||||
|
||||
[[package]]
|
||||
name = "libloading"
|
||||
@ -2471,12 +2386,6 @@ version = "1.7.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "af8b08b04175473088b46763e51ee54da5f9a164bc162f615b91bc179dbf15a3"
|
||||
|
||||
[[package]]
|
||||
name = "opaque-debug"
|
||||
version = "0.2.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c"
|
||||
|
||||
[[package]]
|
||||
name = "opaque-debug"
|
||||
version = "0.3.0"
|
||||
@ -2642,15 +2551,6 @@ dependencies = [
|
||||
"winapi 0.3.9",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "parse-zoneinfo"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c705f256449c60da65e11ff6626e0c16a0a0b96aaa348de61376b249bc340f41"
|
||||
dependencies = [
|
||||
"regex",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "path-slash"
|
||||
version = "0.1.4"
|
||||
@ -2678,40 +2578,6 @@ dependencies = [
|
||||
"ucd-trie",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pest_derive"
|
||||
version = "2.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "833d1ae558dc601e9a60366421196a8d94bc0ac980476d0b67e1d0988d72b2d0"
|
||||
dependencies = [
|
||||
"pest",
|
||||
"pest_generator",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pest_generator"
|
||||
version = "2.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "99b8db626e31e5b81787b9783425769681b347011cc59471e33ea46d2ea0cf55"
|
||||
dependencies = [
|
||||
"pest",
|
||||
"pest_meta",
|
||||
"proc-macro2 1.0.27",
|
||||
"quote 1.0.9",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pest_meta"
|
||||
version = "2.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "54be6e404f5317079812fc8f9f5279de376d8856929e21c184ecf6bbd692a11d"
|
||||
dependencies = [
|
||||
"maplit",
|
||||
"pest",
|
||||
"sha-1 0.8.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pin-project"
|
||||
version = "0.4.28"
|
||||
@ -2795,7 +2661,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "eebcc4aa140b9abd2bc40d9c3f7ccec842679cd79045ac3a7ac698c1a064b7cd"
|
||||
dependencies = [
|
||||
"cpuid-bool",
|
||||
"opaque-debug 0.3.0",
|
||||
"opaque-debug",
|
||||
"universal-hash",
|
||||
]
|
||||
|
||||
@ -2890,7 +2756,6 @@ dependencies = [
|
||||
"shared",
|
||||
"sqlx",
|
||||
"tempdir",
|
||||
"tera",
|
||||
"test_bin",
|
||||
"thiserror",
|
||||
"tokio 0.2.25",
|
||||
@ -3016,7 +2881,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0ef9e7e66b4468674bfcb0c81af8b7fa0bb154fa9f28eb840da5c447baeb8d7e"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"rand_chacha 0.3.0",
|
||||
"rand_chacha 0.3.1",
|
||||
"rand_core 0.6.2",
|
||||
"rand_hc 0.3.0",
|
||||
]
|
||||
@ -3043,9 +2908,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rand_chacha"
|
||||
version = "0.3.0"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e12735cf05c9e10bf21534da50a147b924d555dc7a547c42e6bb2d5b6017ae0d"
|
||||
checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88"
|
||||
dependencies = [
|
||||
"ppv-lite86",
|
||||
"rand_core 0.6.2",
|
||||
@ -3412,9 +3277,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "security-framework"
|
||||
version = "2.3.0"
|
||||
version = "2.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b239a3d5db51252f6f48f42172c65317f37202f4a21021bf5f9d40a408f4592c"
|
||||
checksum = "23a2ac85147a3a11d77ecf1bc7166ec0b92febfa4461c37944e180f319ece467"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"core-foundation",
|
||||
@ -3537,29 +3402,17 @@ dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sha-1"
|
||||
version = "0.8.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f7d94d0bede923b3cea61f3f1ff57ff8cdfd77b400fb8f9998949e0cf04163df"
|
||||
dependencies = [
|
||||
"block-buffer 0.7.3",
|
||||
"digest 0.8.1",
|
||||
"fake-simd",
|
||||
"opaque-debug 0.2.3",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sha-1"
|
||||
version = "0.9.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8c4cfa741c5832d0ef7fab46cabed29c2aae926db0b11bb2069edd8db5e64e16"
|
||||
dependencies = [
|
||||
"block-buffer 0.9.0",
|
||||
"block-buffer",
|
||||
"cfg-if 1.0.0",
|
||||
"cpufeatures",
|
||||
"digest 0.9.0",
|
||||
"opaque-debug 0.3.0",
|
||||
"digest",
|
||||
"opaque-debug",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -3574,11 +3427,11 @@ version = "0.9.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b362ae5752fd2137731f9fa25fd4d9058af34666ca1966fb969119cc35719f12"
|
||||
dependencies = [
|
||||
"block-buffer 0.9.0",
|
||||
"block-buffer",
|
||||
"cfg-if 1.0.0",
|
||||
"cpufeatures",
|
||||
"digest 0.9.0",
|
||||
"opaque-debug 0.3.0",
|
||||
"digest",
|
||||
"opaque-debug",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -3620,15 +3473,6 @@ version = "2.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8347046d4ebd943127157b94d63abb990fcf729dc4e9978927fdf4ac3c998d06"
|
||||
|
||||
[[package]]
|
||||
name = "slug"
|
||||
version = "0.1.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b3bc762e6a4b6c6fcaade73e77f9ebc6991b676f88bb2358bddb56560f073373"
|
||||
dependencies = [
|
||||
"deunicode",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "smallvec"
|
||||
version = "1.6.1"
|
||||
@ -3908,9 +3752,9 @@ checksum = "1e81da0851ada1f3e9d4312c704aa4f8806f0f9d69faaf8df2f3464b4a9437c2"
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "1.0.72"
|
||||
version = "1.0.73"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a1e8cdbefb79a9a5a65e0db8b47b723ee907b7c7f8496c76a1770b5c310bab82"
|
||||
checksum = "f71489ff30030d2ae598524f61326b902466f72a0fb1a8564c001cc63425bcc7"
|
||||
dependencies = [
|
||||
"proc-macro2 1.0.27",
|
||||
"quote 1.0.9",
|
||||
@ -3959,28 +3803,6 @@ dependencies = [
|
||||
"winapi 0.3.9",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tera"
|
||||
version = "1.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "81060acb882480c8793782eb96bc86f5c83d2fc7175ad46c375c6956ef7afa62"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"chrono-tz",
|
||||
"globwalk",
|
||||
"humansize",
|
||||
"lazy_static",
|
||||
"percent-encoding",
|
||||
"pest",
|
||||
"pest_derive",
|
||||
"rand 0.8.3",
|
||||
"regex",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"slug",
|
||||
"unic-segment",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "termcolor"
|
||||
version = "1.1.2"
|
||||
@ -4434,27 +4256,6 @@ version = "0.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "56dee185309b50d1f11bfedef0fe6d036842e3fb77413abef29f8f8d1c5d4c1c"
|
||||
|
||||
[[package]]
|
||||
name = "unic-char-property"
|
||||
version = "0.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a8c57a407d9b6fa02b4795eb81c5b6652060a15a7903ea981f3d723e6c0be221"
|
||||
dependencies = [
|
||||
"unic-char-range",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unic-char-range"
|
||||
version = "0.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0398022d5f700414f6b899e10b8348231abf9173fa93144cbc1a43b9793c1fbc"
|
||||
|
||||
[[package]]
|
||||
name = "unic-common"
|
||||
version = "0.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "80d7ff825a6a654ee85a63e80f92f054f904f21e7d12da4e22f9834a4aaa35bc"
|
||||
|
||||
[[package]]
|
||||
name = "unic-langid"
|
||||
version = "0.9.0"
|
||||
@ -4498,35 +4299,6 @@ dependencies = [
|
||||
"unic-langid-impl",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unic-segment"
|
||||
version = "0.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e4ed5d26be57f84f176157270c112ef57b86debac9cd21daaabbe56db0f88f23"
|
||||
dependencies = [
|
||||
"unic-ucd-segment",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unic-ucd-segment"
|
||||
version = "0.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2079c122a62205b421f499da10f3ee0f7697f012f55b675e002483c73ea34700"
|
||||
dependencies = [
|
||||
"unic-char-property",
|
||||
"unic-char-range",
|
||||
"unic-ucd-version",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unic-ucd-version"
|
||||
version = "0.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "96bd2f2237fe450fcd0a1d2f5f4e91711124f7857ba2e964247776ebeeb7b0c4"
|
||||
dependencies = [
|
||||
"unic-common",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicase"
|
||||
version = "2.6.0"
|
||||
@ -4590,7 +4362,7 @@ version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8326b2c654932e3e4f9196e69d08fdf7cfd718e1dc6f66b347e6024a0c961402"
|
||||
dependencies = [
|
||||
"generic-array 0.14.4",
|
||||
"generic-array",
|
||||
"subtle",
|
||||
]
|
||||
|
||||
|
@ -32,7 +32,6 @@ qrcode = "0.12"
|
||||
rand = "0.8"
|
||||
rpassword = "5.0"
|
||||
serde = "1.0"
|
||||
tera = "1.6"
|
||||
thiserror = "1.0"
|
||||
tracing-actix-web = "0.2.1"
|
||||
tracing-bunyan-formatter = "0.2.0"
|
||||
@ -47,7 +46,6 @@ features = ["serde"]
|
||||
version = "0.4"
|
||||
|
||||
[dependencies.fluent-templates]
|
||||
features = ["tera"]
|
||||
version = "0.6"
|
||||
|
||||
[dependencies.sqlx]
|
||||
|
@ -9,14 +9,12 @@ use actix_files::Files;
|
||||
use actix_identity::{CookieIdentityPolicy, IdentityService};
|
||||
use actix_web::HttpResponse;
|
||||
use actix_web::{web, App, HttpServer};
|
||||
use fluent_templates::{static_loader, FluentLoader};
|
||||
use fluent_templates::static_loader;
|
||||
use qrcode::types::QrError;
|
||||
use shared::datatypes::Secret;
|
||||
use sqlx::{Pool, Sqlite};
|
||||
use std::{fmt::Display, path::PathBuf, str::FromStr};
|
||||
use tera::Tera;
|
||||
use thiserror::Error;
|
||||
use tracing::instrument;
|
||||
use tracing::{error, info, trace};
|
||||
use tracing_actix_web::TracingLogger;
|
||||
|
||||
@ -30,8 +28,6 @@ pub enum ServerError {
|
||||
DatabaseMigration(#[from] sqlx::migrate::MigrateError),
|
||||
#[error("The environment file could not be read")]
|
||||
Environment(#[from] std::env::VarError),
|
||||
#[error("The templates could not be rendered correctly: {0}")]
|
||||
Template(#[from] tera::Error),
|
||||
#[error("The qr-code could not be generated: {0}")]
|
||||
Qr(#[from] QrError),
|
||||
#[error("Some error happened during input and output: {0}")]
|
||||
@ -98,13 +94,6 @@ impl actix_web::error::ResponseError for ServerError {
|
||||
"This Server is not properly configured, if you are the admin look into the installation- or update instructions!",
|
||||
))
|
||||
}
|
||||
Self::Template(e) => {
|
||||
eprintln!("Template Error happened: {:?}", e);
|
||||
HttpResponse::InternalServerError().body(&Self::render_error(
|
||||
"Server Error",
|
||||
"The templates could not be rendered.",
|
||||
))
|
||||
}
|
||||
Self::Qr(e) => {
|
||||
eprintln!("QR Error happened: {:?}", e);
|
||||
HttpResponse::InternalServerError().body(&Self::render_error(
|
||||
@ -206,51 +195,6 @@ static_loader! {
|
||||
};
|
||||
}
|
||||
|
||||
#[instrument]
|
||||
fn build_tera() -> Result<Tera, ServerError> {
|
||||
let mut tera = Tera::default();
|
||||
|
||||
// Add translation support
|
||||
tera.register_function("fluent", FluentLoader::new(&*LOCALES));
|
||||
|
||||
tera.add_raw_templates(vec![
|
||||
("admin.html", include_str!("../templates/admin.html")),
|
||||
("base.html", include_str!("../templates/base.html")),
|
||||
(
|
||||
"edit_link.html",
|
||||
include_str!("../templates/edit_link.html"),
|
||||
),
|
||||
(
|
||||
"edit_profile.html",
|
||||
include_str!("../templates/edit_profile.html"),
|
||||
),
|
||||
(
|
||||
"index_users.html",
|
||||
include_str!("../templates/index_users.html"),
|
||||
),
|
||||
("index.html", include_str!("../templates/index.html")),
|
||||
("login.html", include_str!("../templates/login.html")),
|
||||
(
|
||||
"not_found.html",
|
||||
include_str!("../templates/not_found.html"),
|
||||
),
|
||||
("signup.html", include_str!("../templates/signup.html")),
|
||||
(
|
||||
"submission.html",
|
||||
include_str!("../templates/submission.html"),
|
||||
),
|
||||
(
|
||||
"view_link.html",
|
||||
include_str!("../templates/view_link.html"),
|
||||
),
|
||||
(
|
||||
"view_profile.html",
|
||||
include_str!("../templates/view_profile.html"),
|
||||
),
|
||||
])?;
|
||||
Ok(tera)
|
||||
}
|
||||
|
||||
/// Launch the pslink-webservice
|
||||
///
|
||||
/// # Errors
|
||||
@ -270,7 +214,6 @@ pub async fn webservice(
|
||||
"If the public url is set up correctly it should be accessible via: {}://{}/admin/login/",
|
||||
&server_config.protocol, &server_config.public_url
|
||||
);
|
||||
let tera = build_tera().expect("Failed to build Templates");
|
||||
trace!("The tera templates are ready");
|
||||
|
||||
let server = HttpServer::new(move || {
|
||||
@ -283,7 +226,6 @@ pub async fn webservice(
|
||||
.name("auth-cookie")
|
||||
.secure(true),
|
||||
))
|
||||
.data(tera.clone())
|
||||
.service(actix_web_static_files::ResourceFiles::new(
|
||||
"/static", generated,
|
||||
))
|
||||
@ -292,60 +234,6 @@ pub async fn webservice(
|
||||
// admin block
|
||||
.service(
|
||||
web::scope("/admin")
|
||||
// list all links
|
||||
.route("/index/", web::get().to(views::index))
|
||||
// invite users
|
||||
.route("/signup/", web::get().to(views::signup))
|
||||
.route("/signup/", web::post().to(views::process_signup))
|
||||
// logout
|
||||
.route("/logout/", web::to(views::logout))
|
||||
// submit a new url for shortening
|
||||
.route("/submit/", web::get().to(views::create_link))
|
||||
.route("/submit/", web::post().to(views::process_link_creation))
|
||||
// view an existing url
|
||||
.service(
|
||||
web::scope("/view")
|
||||
.service(
|
||||
web::scope("/link")
|
||||
.route("/{redirect_id}", web::get().to(views::view_link))
|
||||
.route("/", web::get().to(views::view_link_empty)),
|
||||
)
|
||||
.service(
|
||||
web::scope("/profile")
|
||||
.route("/{user_id}", web::get().to(views::view_profile)),
|
||||
)
|
||||
.route("/users/", web::get().to(views::index_users)),
|
||||
)
|
||||
.service(
|
||||
web::scope("/edit")
|
||||
.service(
|
||||
web::scope("/link")
|
||||
.route("/{redirect_id}", web::get().to(views::edit_link))
|
||||
.route(
|
||||
"/{redirect_id}",
|
||||
web::post().to(views::process_link_edit),
|
||||
),
|
||||
)
|
||||
.service(
|
||||
web::scope("/profile")
|
||||
.route("/{user_id}", web::get().to(views::edit_profile))
|
||||
.route(
|
||||
"/{user_id}",
|
||||
web::post().to(views::process_edit_profile),
|
||||
),
|
||||
)
|
||||
.route("/set_admin/{user_id}", web::get().to(views::toggle_admin))
|
||||
.route(
|
||||
"/set_language/{language}",
|
||||
web::get().to(views::set_language),
|
||||
),
|
||||
)
|
||||
.service(
|
||||
web::scope("/delete").service(
|
||||
web::scope("/link")
|
||||
.route("/{redirect_id}", web::get().to(views::process_link_delete)),
|
||||
),
|
||||
)
|
||||
.service(
|
||||
web::scope("/download")
|
||||
.route("/png/{redirect_id}", web::get().to(views::download_png)),
|
||||
@ -357,7 +245,6 @@ pub async fn webservice(
|
||||
"/create_link/",
|
||||
web::post().to(views::process_create_link_json),
|
||||
)
|
||||
.route("/get_qr_code/", web::post().to(views::get_qr_code_json))
|
||||
.route(
|
||||
"/edit_link/",
|
||||
web::post().to(views::process_update_link_json),
|
||||
@ -380,11 +267,9 @@ pub async fn webservice(
|
||||
web::post().to(views::get_logged_user_json),
|
||||
)
|
||||
.route("/login_user/", web::post().to(views::process_login_json)),
|
||||
)
|
||||
// login to the admin area
|
||||
.route("/login/", web::get().to(views::login))
|
||||
.route("/login/", web::post().to(views::process_login)),
|
||||
),
|
||||
)
|
||||
// Serve the Wasm App for the admin interface.
|
||||
.service(
|
||||
web::scope("/app")
|
||||
.service(Files::new("/pkg", "./app/pkg"))
|
||||
|
@ -12,18 +12,15 @@ use fluent_langneg::{
|
||||
};
|
||||
use fluent_templates::LanguageIdentifier;
|
||||
use image::{DynamicImage, ImageOutputFormat, Luma};
|
||||
use qrcode::{render::svg, QrCode};
|
||||
use qrcode::QrCode;
|
||||
use queries::{authenticate, Role};
|
||||
use shared::apirequests::{
|
||||
general::{Message, Status},
|
||||
links::{LinkDelta, LinkRequestForm, QrCodeRequest, SvgQrCodeResponse},
|
||||
links::{LinkDelta, LinkRequestForm},
|
||||
users::{LoginUser, UserDelta, UserRequestForm},
|
||||
};
|
||||
use tera::{Context, Tera};
|
||||
use tracing::{error, info, instrument, warn};
|
||||
|
||||
use crate::forms::LinkForm;
|
||||
use crate::models::NewUser;
|
||||
use crate::queries;
|
||||
use crate::ServerError;
|
||||
|
||||
@ -94,30 +91,6 @@ pub async fn wasm_app(config: web::Data<crate::ServerConfig>) -> Result<HttpResp
|
||||
))
|
||||
}
|
||||
|
||||
/// Show the list of all available links if a user is authenticated
|
||||
|
||||
#[instrument(skip(id, tera))]
|
||||
pub async fn index(
|
||||
tera: web::Data<Tera>,
|
||||
config: web::Data<crate::ServerConfig>,
|
||||
id: Identity,
|
||||
) -> Result<HttpResponse, ServerError> {
|
||||
match queries::list_all_allowed(&id, &config, LinkRequestForm::default()).await {
|
||||
Ok(links) => {
|
||||
let mut data = Context::new();
|
||||
data.insert("user", &links.user);
|
||||
data.insert("title", &format!("Links der {}", &config.brand_name,));
|
||||
data.insert("links_per_users", &links.list);
|
||||
let rendered = tera.render("index.html", &data)?;
|
||||
Ok(HttpResponse::Ok().body(rendered))
|
||||
}
|
||||
Err(e) => {
|
||||
error!("Failed to get the links: {:?}", e);
|
||||
Ok(redirect_builder("/admin/login/"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[instrument(skip(id))]
|
||||
pub async fn index_json(
|
||||
config: web::Data<crate::ServerConfig>,
|
||||
@ -135,25 +108,6 @@ pub async fn index_json(
|
||||
}
|
||||
}
|
||||
|
||||
/// Show the list of all available links if a user is authenticated
|
||||
#[instrument(skip(id, tera))]
|
||||
pub async fn index_users(
|
||||
tera: web::Data<Tera>,
|
||||
config: web::Data<crate::ServerConfig>,
|
||||
id: Identity,
|
||||
) -> Result<HttpResponse, ServerError> {
|
||||
if let Ok(users) = queries::list_users(&id, &config, UserRequestForm::default()).await {
|
||||
let mut data = Context::new();
|
||||
data.insert("user", &users.user);
|
||||
data.insert("title", &format!("Benutzer der {}", &config.brand_name,));
|
||||
data.insert("users", &users.list);
|
||||
|
||||
let rendered = tera.render("index_users.html", &data)?;
|
||||
Ok(HttpResponse::Ok().body(rendered))
|
||||
} else {
|
||||
Ok(redirect_builder("/admin/login"))
|
||||
}
|
||||
}
|
||||
#[instrument(skip(id))]
|
||||
pub async fn index_users_json(
|
||||
config: web::Data<crate::ServerConfig>,
|
||||
@ -179,149 +133,6 @@ pub async fn get_logged_user_json(
|
||||
}
|
||||
}
|
||||
|
||||
#[instrument(skip(id, tera))]
|
||||
pub async fn view_link_empty(
|
||||
tera: web::Data<Tera>,
|
||||
config: web::Data<crate::ServerConfig>,
|
||||
id: Identity,
|
||||
) -> Result<HttpResponse, ServerError> {
|
||||
view_link(tera, config, id, web::Path::from("".to_owned())).await
|
||||
}
|
||||
|
||||
pub async fn get_qr_code_json(
|
||||
config: web::Data<crate::ServerConfig>,
|
||||
qr_request: web::Json<QrCodeRequest>,
|
||||
id: Identity,
|
||||
) -> Result<HttpResponse, ServerError> {
|
||||
if let Ok(link) = queries::get_link(&id, &qr_request.link_id, &config).await {
|
||||
let host = config.public_url.to_string();
|
||||
let qr = QrCode::with_error_correction_level(
|
||||
&format!("http://{}/{}", &host, &link.item.code),
|
||||
qrcode::EcLevel::L,
|
||||
)?;
|
||||
|
||||
let svg = qr
|
||||
.render()
|
||||
.min_dimensions(100, 100)
|
||||
.dark_color(svg::Color("#000000"))
|
||||
.light_color(svg::Color("#ffffff"))
|
||||
.build();
|
||||
|
||||
Ok(HttpResponse::Ok().json2(&SvgQrCodeResponse { svg }))
|
||||
} else {
|
||||
Ok(redirect_builder("/admin/login/"))
|
||||
}
|
||||
}
|
||||
|
||||
#[instrument(skip(id, tera))]
|
||||
pub async fn view_link(
|
||||
tera: web::Data<Tera>,
|
||||
config: web::Data<crate::ServerConfig>,
|
||||
id: Identity,
|
||||
link_id: web::Path<String>,
|
||||
) -> Result<HttpResponse, ServerError> {
|
||||
if let Ok(link) = queries::get_link(&id, &link_id.0, &config).await {
|
||||
let host = config.public_url.to_string();
|
||||
let protocol = config.protocol.to_string();
|
||||
let qr = QrCode::with_error_correction_level(
|
||||
&format!("http://{}/{}", &host, &link.item.code),
|
||||
qrcode::EcLevel::L,
|
||||
)?;
|
||||
|
||||
let svg = qr
|
||||
.render()
|
||||
.min_dimensions(100, 100)
|
||||
.dark_color(svg::Color("#000000"))
|
||||
.light_color(svg::Color("#ffffff"))
|
||||
.build();
|
||||
|
||||
let mut data = Context::new();
|
||||
data.insert("user", &link.user);
|
||||
data.insert(
|
||||
"title",
|
||||
&format!("Links {} der {}", &link.item.code, &config.brand_name,),
|
||||
);
|
||||
data.insert("link", &link.item);
|
||||
data.insert("qr", &svg);
|
||||
data.insert("host", &host);
|
||||
data.insert("protocol", &protocol);
|
||||
|
||||
let rendered = tera.render("view_link.html", &data)?;
|
||||
Ok(HttpResponse::Ok().body(rendered))
|
||||
} else {
|
||||
Ok(redirect_builder("/admin/login/"))
|
||||
}
|
||||
}
|
||||
|
||||
#[instrument(skip(id, tera))]
|
||||
pub async fn view_profile(
|
||||
tera: web::Data<Tera>,
|
||||
config: web::Data<crate::ServerConfig>,
|
||||
id: Identity,
|
||||
user_id: web::Path<String>,
|
||||
) -> Result<HttpResponse, ServerError> {
|
||||
info!("Viewing Profile!");
|
||||
if let Ok(query) = queries::get_user(&id, &user_id.0, &config).await {
|
||||
let mut data = Context::new();
|
||||
data.insert("user", &query.user);
|
||||
data.insert(
|
||||
"title",
|
||||
&format!(
|
||||
"Benutzer {} der {}",
|
||||
&query.item.username, &config.brand_name,
|
||||
),
|
||||
);
|
||||
data.insert("viewed_user", &query.item);
|
||||
|
||||
let rendered = tera.render("view_profile.html", &data)?;
|
||||
Ok(HttpResponse::Ok().body(rendered))
|
||||
} else {
|
||||
// Parsing error -- do something else
|
||||
Ok(redirect_builder("/admin/login/"))
|
||||
}
|
||||
}
|
||||
|
||||
#[instrument(skip(id, tera))]
|
||||
pub async fn edit_profile(
|
||||
tera: web::Data<Tera>,
|
||||
config: web::Data<crate::ServerConfig>,
|
||||
id: Identity,
|
||||
user_id: web::Path<String>,
|
||||
) -> Result<HttpResponse, ServerError> {
|
||||
info!("Editing Profile!");
|
||||
if let Ok(query) = queries::get_user(&id, &user_id.0, &config).await {
|
||||
let mut data = Context::new();
|
||||
data.insert("user", &query.user);
|
||||
data.insert(
|
||||
"title",
|
||||
&format!(
|
||||
"Benutzer {} der {}",
|
||||
&query.user.username, &config.brand_name,
|
||||
),
|
||||
);
|
||||
data.insert("user", &query.user);
|
||||
|
||||
let rendered = tera.render("edit_profile.html", &data)?;
|
||||
Ok(HttpResponse::Ok().body(rendered))
|
||||
} else {
|
||||
Ok(redirect_builder("/admin/login/"))
|
||||
}
|
||||
}
|
||||
|
||||
#[instrument(skip(id))]
|
||||
pub async fn process_edit_profile(
|
||||
data: web::Form<NewUser>,
|
||||
config: web::Data<crate::ServerConfig>,
|
||||
id: Identity,
|
||||
user_id: web::Path<String>,
|
||||
) -> Result<HttpResponse, ServerError> {
|
||||
let query = queries::update_user(&id, &user_id.0, &config, &data).await?;
|
||||
Ok(redirect_builder(&format!(
|
||||
"admin/view/profile/{}",
|
||||
query.user.username
|
||||
)))
|
||||
}
|
||||
|
||||
#[instrument(skip(id))]
|
||||
pub async fn download_png(
|
||||
id: Identity,
|
||||
@ -347,42 +158,6 @@ pub async fn download_png(
|
||||
}
|
||||
}
|
||||
|
||||
#[instrument(skip(id, tera))]
|
||||
pub async fn signup(
|
||||
tera: web::Data<Tera>,
|
||||
config: web::Data<crate::ServerConfig>,
|
||||
id: Identity,
|
||||
) -> Result<HttpResponse, ServerError> {
|
||||
match queries::authenticate(&id, &config).await? {
|
||||
queries::Role::Admin { user } => {
|
||||
let mut data = Context::new();
|
||||
data.insert("title", "Ein Benutzerkonto erstellen");
|
||||
data.insert("user", &user);
|
||||
|
||||
let rendered = tera.render("signup.html", &data)?;
|
||||
Ok(HttpResponse::Ok().body(rendered))
|
||||
}
|
||||
queries::Role::Regular { .. }
|
||||
| queries::Role::NotAuthenticated
|
||||
| queries::Role::Disabled => Ok(redirect_builder("/admin/login/")),
|
||||
}
|
||||
}
|
||||
|
||||
#[instrument(skip(id))]
|
||||
pub async fn process_signup(
|
||||
data: web::Form<NewUser>,
|
||||
config: web::Data<crate::ServerConfig>,
|
||||
id: Identity,
|
||||
) -> Result<HttpResponse, ServerError> {
|
||||
info!("Creating a User: {:?}", &data);
|
||||
match queries::create_user(&id, &data, &config).await {
|
||||
Ok(item) => {
|
||||
Ok(HttpResponse::Ok().body(format!("Successfully saved user: {}", item.item.username)))
|
||||
}
|
||||
Err(e) => Err(e),
|
||||
}
|
||||
}
|
||||
|
||||
#[instrument(skip(id))]
|
||||
pub async fn process_create_user_json(
|
||||
config: web::Data<crate::ServerConfig>,
|
||||
@ -436,81 +211,6 @@ pub async fn set_language(
|
||||
Ok(redirect_builder("/admin/index/"))
|
||||
}
|
||||
|
||||
#[instrument(skip(tera, id))]
|
||||
pub async fn login(
|
||||
tera: web::Data<Tera>,
|
||||
id: Identity,
|
||||
config: web::Data<crate::ServerConfig>,
|
||||
req: HttpRequest,
|
||||
) -> Result<HttpResponse, ServerError> {
|
||||
let language_code = detect_language(&req).unwrap_or_else(|_| "en".to_string());
|
||||
info!("Detected languagecode: {}", &language_code);
|
||||
let mut data = Context::new();
|
||||
data.insert("title", "Login");
|
||||
data.insert("language", &language_code);
|
||||
|
||||
if id.identity().is_some() {
|
||||
if let Ok(r) = authenticate(&id, &config).await {
|
||||
match r {
|
||||
Role::Admin { user } | Role::Regular { user } => {
|
||||
info!(
|
||||
"This user ({}) is already logged in redirecting to /admin/index/",
|
||||
user.username
|
||||
);
|
||||
return Ok(redirect_builder("/admin/index/"));
|
||||
}
|
||||
Role::Disabled | Role::NotAuthenticated => (),
|
||||
}
|
||||
}
|
||||
warn!("Invalid user session. The user might be deleted or something tampered with the cookies.");
|
||||
id.forget();
|
||||
}
|
||||
|
||||
let rendered = tera.render("login.html", &data)?;
|
||||
Ok(HttpResponse::Ok().body(rendered))
|
||||
}
|
||||
|
||||
#[instrument(skip(id))]
|
||||
pub async fn process_login(
|
||||
data: web::Form<LoginUser>,
|
||||
config: web::Data<crate::ServerConfig>,
|
||||
id: Identity,
|
||||
) -> Result<HttpResponse, ServerError> {
|
||||
let user = queries::get_user_by_name(&data.username, &config).await;
|
||||
|
||||
match user {
|
||||
Ok(u) => {
|
||||
if let Some(hash) = u.password.secret {
|
||||
let secret = &config.secret;
|
||||
let valid = Verifier::default()
|
||||
.with_hash(hash)
|
||||
.with_password(&data.password)
|
||||
.with_secret_key(secret.secret.as_ref().expect("No secret available"))
|
||||
.verify()?;
|
||||
|
||||
if valid {
|
||||
info!("Log-in of user: {}", &u.username);
|
||||
let session_token = u.username;
|
||||
id.remember(session_token);
|
||||
Ok(redirect_builder("/admin/index/"))
|
||||
} else {
|
||||
Ok(redirect_builder("/admin/login/"))
|
||||
}
|
||||
} else {
|
||||
Ok(HttpResponse::Unauthorized().json2(&Status::Error(Message {
|
||||
message: "Failed to Login".to_string(),
|
||||
})))
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
info!("Failed to login: {}", e);
|
||||
Ok(HttpResponse::Unauthorized().json2(&Status::Error(Message {
|
||||
message: "Failed to Login".to_string(),
|
||||
})))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[instrument(skip(id))]
|
||||
pub async fn process_login_json(
|
||||
data: web::Json<LoginUser>,
|
||||
@ -559,16 +259,8 @@ pub async fn process_login_json(
|
||||
}
|
||||
}
|
||||
|
||||
#[instrument(skip(id))]
|
||||
pub async fn logout(id: Identity) -> Result<HttpResponse, ServerError> {
|
||||
info!("Logging out the user");
|
||||
id.forget();
|
||||
Ok(redirect_builder("/admin/login/"))
|
||||
}
|
||||
|
||||
#[instrument(skip(tera))]
|
||||
#[instrument()]
|
||||
pub async fn redirect(
|
||||
tera: web::Data<Tera>,
|
||||
config: web::Data<crate::ServerConfig>,
|
||||
data: web::Path<String>,
|
||||
req: HttpRequest,
|
||||
@ -586,12 +278,23 @@ pub async fn redirect(
|
||||
"Link was not found: http://{}/{} \n {}",
|
||||
&config.public_url, &data.0, e
|
||||
);
|
||||
let mut data = Context::new();
|
||||
data.insert("title", "Wurde gel\u{f6}scht");
|
||||
let language = detect_language(&req).unwrap_or_else(|_| "en".to_string());
|
||||
data.insert("language", &language);
|
||||
let rendered = tera.render("not_found.html", &data)?;
|
||||
Ok(HttpResponse::NotFound().body(rendered))
|
||||
Ok(HttpResponse::NotFound().body(
|
||||
r#"<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>{{title}}</title>
|
||||
<meta name="author" content="Franz Dietrich">
|
||||
<meta http-equiv="robots" content="[noindex|nofollow]">
|
||||
<link rel="stylesheet" href="/static/style.css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="content">
|
||||
This link was either deleted or does not exist.
|
||||
</div>
|
||||
</body>
|
||||
</html>"#,
|
||||
))
|
||||
}
|
||||
Err(e) => Err(e),
|
||||
}
|
||||
@ -634,82 +337,6 @@ pub async fn process_update_link_json(
|
||||
}
|
||||
}
|
||||
|
||||
#[instrument(skip(id))]
|
||||
pub async fn create_link(
|
||||
tera: web::Data<Tera>,
|
||||
config: web::Data<crate::ServerConfig>,
|
||||
id: Identity,
|
||||
) -> Result<HttpResponse, ServerError> {
|
||||
match queries::authenticate(&id, &config).await? {
|
||||
queries::Role::Admin { user } | queries::Role::Regular { user } => {
|
||||
let mut data = Context::new();
|
||||
data.insert("title", "Einen Kurzlink erstellen");
|
||||
|
||||
data.insert("user", &user);
|
||||
let rendered = tera.render("submission.html", &data)?;
|
||||
Ok(HttpResponse::Ok().body(rendered))
|
||||
}
|
||||
queries::Role::NotAuthenticated | queries::Role::Disabled => {
|
||||
Ok(redirect_builder("/admin/login/"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[instrument(skip(id))]
|
||||
pub async fn process_link_creation(
|
||||
data: web::Form<LinkForm>,
|
||||
config: web::Data<crate::ServerConfig>,
|
||||
id: Identity,
|
||||
) -> Result<HttpResponse, ServerError> {
|
||||
let new_link = queries::create_link(&id, data, &config).await?;
|
||||
Ok(redirect_builder(&format!(
|
||||
"/admin/view/link/{}",
|
||||
new_link.item.code
|
||||
)))
|
||||
}
|
||||
|
||||
#[instrument(skip(id))]
|
||||
pub async fn edit_link(
|
||||
tera: web::Data<Tera>,
|
||||
config: web::Data<crate::ServerConfig>,
|
||||
id: Identity,
|
||||
link_id: web::Path<String>,
|
||||
) -> Result<HttpResponse, ServerError> {
|
||||
if let Ok(query) = queries::get_link(&id, &link_id.0, &config).await {
|
||||
let mut data = Context::new();
|
||||
data.insert("title", "Submit a Post");
|
||||
data.insert("link", &query.item);
|
||||
|
||||
data.insert("user", &query.user);
|
||||
let rendered = tera.render("edit_link.html", &data)?;
|
||||
return Ok(HttpResponse::Ok().body(rendered));
|
||||
}
|
||||
Ok(redirect_builder("/admin/login/"))
|
||||
}
|
||||
pub async fn process_link_edit(
|
||||
data: web::Form<LinkForm>,
|
||||
config: web::Data<crate::ServerConfig>,
|
||||
id: Identity,
|
||||
link_code: web::Path<String>,
|
||||
) -> Result<HttpResponse, ServerError> {
|
||||
match queries::update_link(&id, &link_code.0, data, &config).await {
|
||||
Ok(query) => Ok(redirect_builder(&format!(
|
||||
"/admin/view/link/{}",
|
||||
&query.item.code
|
||||
))),
|
||||
Err(e) => Err(e),
|
||||
}
|
||||
}
|
||||
|
||||
#[instrument(skip(id))]
|
||||
pub async fn process_link_delete(
|
||||
id: Identity,
|
||||
config: web::Data<crate::ServerConfig>,
|
||||
link_code: web::Path<String>,
|
||||
) -> Result<HttpResponse, ServerError> {
|
||||
queries::delete_link(&id, &link_code.0, &config).await?;
|
||||
Ok(redirect_builder("/admin/login/"))
|
||||
}
|
||||
#[instrument(skip(id))]
|
||||
pub async fn process_delete_link_json(
|
||||
id: Identity,
|
||||
|
Loading…
Reference in New Issue
Block a user