From 0d62cec021750e42e1b14f6a0d33db998fbffe4a Mon Sep 17 00:00:00 2001 From: Tim Date: Thu, 15 May 2025 20:09:08 +0200 Subject: Change oauth flow + create api route to create new category --- src/chef/pages/admin.clj | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'src/chef/pages/admin.clj') diff --git a/src/chef/pages/admin.clj b/src/chef/pages/admin.clj index 9aaade3..fb6eeee 100644 --- a/src/chef/pages/admin.clj +++ b/src/chef/pages/admin.clj @@ -17,15 +17,20 @@ [:input {:type :text :placeholder "Frage" :style {:display :inline-block :width :auto}}] ; TODO: only show when category has children - [:img {:src "/static/icons/plus.svg" :height "30em" - :style {:vertical-align :middle - :margin-left "1em"}}]]] + [:img {:src "/static/icons/plus.svg" :height "30em" + :style {:vertical-align :middle + :margin-left "1em"} + :hx-post "/api/admin/create-category" + :hx-swap "none"}]]] [:h2 "Rezepte"] [:i "Coming soon..."])) (defn handler [req] - (cutils/auth-only req - (-> (render) - html/html - str - ruresp/response))) + (let [access-token (get-in req [:oauth2/access-tokens :auth]) + resp (-> (render) + html/html + str + ruresp/response)] + (if (some? access-token) + (assoc resp :session (assoc (:session req) :oauth-token access-token)) + (cutils/auth-only req resp)))) -- cgit v1.2.3