From ffb4014db2a9cf56a434684511b5c871e95234d0 Mon Sep 17 00:00:00 2001 From: Laurence Chen Date: Thu, 8 Aug 2024 11:53:54 +0800 Subject: [PATCH] change the name of by-path middleware --- src/co/gaiwan/compass/routes/profiles.clj | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/co/gaiwan/compass/routes/profiles.clj b/src/co/gaiwan/compass/routes/profiles.clj index 4568ae5..c90590a 100644 --- a/src/co/gaiwan/compass/routes/profiles.clj +++ b/src/co/gaiwan/compass/routes/profiles.clj @@ -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 @@ -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}}]])