Skip to content

Commit

Permalink
change the name of by-path middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
humorless committed Aug 8, 2024
1 parent 5e8ac18 commit ffb4014
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/co/gaiwan/compass/routes/profiles.clj
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@
[io.pedestal.log :as log]
[java-time.api :as time]))

(defn wrap-login-check [handler]
(defn wrap-authentication [handler]
(fn [req]
(log/trace ::login-check (:identity req))
(if-let [user (:identity req)]
(handler req)
(util/redirect (oauth/flow-init-url {:redirect-url "/profiles"})))))
{:status 401
:headers {"Content-Type" "text/plain"}
:body "Unauthorized"})))

(defn GET-profile [req]
{:html/body [h/profile-detail
Expand Down Expand Up @@ -44,10 +46,10 @@
(defn routes []
["/profiles"
[""
{:middleware [wrap-login-check]
{:middleware [wrap-authentication]
:get {:handler GET-profile}}]
["/edit"
{:get {:handler GET-profile-form}}]
["/save"
{:middleware [wrap-login-check]
{:middleware [wrap-authentication]
:post {:handler POST-save-profile}}]])

0 comments on commit ffb4014

Please sign in to comment.