Revamps all of the IOL's routing, so that the new history page can share with the rest.

This commit is contained in:
2023-01-12 16:56:40 -08:00
parent ce01a63797
commit 46dd191391
29 changed files with 1294 additions and 1053 deletions

View File

@@ -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))))