From bf56a0dbe5d39cde6c7c10ebf5195d176ecf3510 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ellis=20Keny=C5=91?= Date: Thu, 12 Oct 2023 16:02:52 +0100 Subject: [PATCH] Stylize the login form (#31) --- .../operations/create-login-resource.edn | 63 +++++-------- .../auth.example.org/operations/login.html | 90 +++++++++++++++++++ 2 files changed, 111 insertions(+), 42 deletions(-) create mode 100644 installers/auth.example.org/operations/login.html diff --git a/installers/auth.example.org/operations/create-login-resource.edn b/installers/auth.example.org/operations/create-login-resource.edn index d29e56034..546a626fc 100644 --- a/installers/auth.example.org/operations/create-login-resource.edn +++ b/installers/auth.example.org/operations/create-login-resource.edn @@ -17,57 +17,36 @@ :juxt.site/prepare {:juxt.site.sci/program #juxt.pprint - (let [content-type (-> *ctx* - :juxt.site/received-representation - :juxt.http/content-type) - body (-> *ctx* - :juxt.site/received-representation - :juxt.http/body)] - (case content-type - "application/edn" - (some-> - body - (String.) - clojure.edn/read-string - juxt.site.malli/validate-input - (assoc - :juxt.site/methods - {:get {:juxt.site/operation "https://auth.example.org/operations/get-unprotected-resource"} - :post {:juxt.site/operation "https://auth.example.org/operations/login"}} + (let [content-type (-> *ctx* + :juxt.site/received-representation + :juxt.http/content-type) + body (-> *ctx* + :juxt.site/received-representation + :juxt.http/body)] + (case content-type + "application/edn" + (some-> + body + (String.) + clojure.edn/read-string + juxt.site.malli/validate-input + (assoc + :juxt.site/methods + {:get {:juxt.site/operation "https://auth.example.org/operations/get-unprotected-resource"} + :post {:juxt.site/operation "https://auth.example.org/operations/login"}} - :juxt.http/content-type "text/html;charset=utf-8" + :juxt.http/content-type "text/html;charset=utf-8" ;; TODO: We could make the HTML content a parameter ;; Note: It helps security if the http methods remain unconfigurable. - :juxt.http/content " - - - - - - -
-

-Username: -

-

-Password: -

-

- -

-
- - -\r\n"))))} + :juxt.http/content #juxt.template #juxt.include "login.html"))))} :juxt.site/transact {:juxt.site.sci/program #juxt.pprint - [[:xtdb.api/put *prepare*]]} + [[:xtdb.api/put *prepare*]]} :juxt.site/rules - [ - [(allowed? subject operation resource permission) + [[(allowed? subject operation resource permission) [permission :juxt.site/subject subject]] [(allowed? subject operation resource permission) diff --git a/installers/auth.example.org/operations/login.html b/installers/auth.example.org/operations/login.html new file mode 100644 index 000000000..6128fb3fa --- /dev/null +++ b/installers/auth.example.org/operations/login.html @@ -0,0 +1,90 @@ + + + + + + + + Login + + + + + + + +
+
+
+
+
+
+

Login

+
+
+ + + + + + +
+
+
+
+ + + + + + +
+ + +
+
+ +
+
+
+
+
+
+
+ + + +