From 9eaf121454a0245a1d5608e7b9773f1a711621fe Mon Sep 17 00:00:00 2001 From: Alex Wright Date: Sat, 29 Feb 2020 20:23:48 +0100 Subject: [PATCH] Adding route for login and login_form The EmptyContext is probably dumb or at least goofy.. but I can't work out a better way of making render() happy right now. --- src/main.rs | 11 +++++++++++ templates/hello.html.tera | 21 ++------------------- templates/login_form.html.tera | 23 +++++++++++++++++++++++ 3 files changed, 36 insertions(+), 19 deletions(-) create mode 100644 templates/login_form.html.tera diff --git a/src/main.rs b/src/main.rs index 6a0fd8c..8bd49dd 100644 --- a/src/main.rs +++ b/src/main.rs @@ -109,6 +109,16 @@ struct LoginData { password: String, } +#[derive(Serialize)] +struct EmptyContext { +} + +#[get("/login")] +fn login_form() -> Template { + let context = EmptyContext {}; + Template::render("login_form", &context) +} + #[post("/login", data = "")] fn login(form_data: Form) -> String { let auth = BasicAuthentication { @@ -188,6 +198,7 @@ fn routes() -> Vec { oidc_config, get_keys, login, + login_form, ] } diff --git a/templates/hello.html.tera b/templates/hello.html.tera index e696abd..8321d74 100644 --- a/templates/hello.html.tera +++ b/templates/hello.html.tera @@ -1,23 +1,6 @@ {% extends "base" %} {% block content %} -

Login

-
-
- Login -
- - - -
-
- - - -
-
- -
-
-
+

Hello?

+ Login {% endblock content %} diff --git a/templates/login_form.html.tera b/templates/login_form.html.tera new file mode 100644 index 0000000..e696abd --- /dev/null +++ b/templates/login_form.html.tera @@ -0,0 +1,23 @@ +{% extends "base" %} + +{% block content %} +

Login

+
+
+ Login +
+ + + +
+
+ + + +
+
+ +
+
+
+{% endblock content %}