Skip to content

Commit

Permalink
Create gate-keeper middleware fn to restrict access to non-public routes
Browse files Browse the repository at this point in the history
  • Loading branch information
the-dress-code committed Feb 5, 2024
1 parent 93da094 commit bd780f6
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/middleware.clj
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,26 @@
(if (some? (get-in request [:session :member/email]))
(handler request)
(coast/unauthorized "HAL9000 says: I'm sorry Wendy, I can't let you do that"))))

(defn gate-keeper [handler]
(fn [request]
(let [public-routes {"/sign-up" :public
"/members" :public
"/login" :public
"/sessions" :public}]
(if (= :public (get public-routes (:uri request)))
(handler request)
(coast/unauthorized "No.")))))

;; update line 19 to the following:
#_(coast/redirect-to :member/build)

(comment

(def debug-m (atom nil))

(add-tap #(reset! debug-m %))

@debug-m

)

0 comments on commit bd780f6

Please sign in to comment.