Revamps all of the IOL's routing, so that the new history page can share with the rest.
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
(ns auto-ap.routes.utils
|
||||
(:require [buddy.auth :refer [authenticated?]]))
|
||||
(:require
|
||||
[auto-ap.graphql.utils :refer [is-admin?]]
|
||||
[buddy.auth :refer [authenticated?]]
|
||||
[auto-ap.logging :as alog]))
|
||||
|
||||
(defn wrap-secure [handler]
|
||||
(fn [request]
|
||||
@@ -7,3 +10,20 @@
|
||||
(handler request)
|
||||
{:status 401
|
||||
:body "not authenticated"})))
|
||||
|
||||
(defn wrap-admin [handler]
|
||||
(fn [request]
|
||||
(if (is-admin? (:identity request))
|
||||
(handler request)
|
||||
(do
|
||||
(alog/warn ::unauthenticated)
|
||||
{:status 302
|
||||
:headers "/login"}))))
|
||||
|
||||
(defn wrap-client-redirect-unauthenticated [handler]
|
||||
(fn [request]
|
||||
(let [response (handler request)]
|
||||
(println )
|
||||
(if (= 401 (get response :status))
|
||||
(assoc-in response [:headers "hx-redirect"] "/login/")
|
||||
response))))
|
||||
|
||||
Reference in New Issue
Block a user