revamped logging!

This commit is contained in:
Bryce Covert
2020-08-01 17:07:17 -07:00
parent 49f98522c0
commit 51b097766f
33 changed files with 598 additions and 485 deletions

View File

@@ -1,7 +1,8 @@
(ns auto-ap.graphql.utils
(:require [clojure.string :as str]
[buddy.auth :refer [throw-unauthorized]]
[clojure.walk :as walk]))
[clojure.walk :as walk]
[clojure.tools.logging :as log]))
(defn snake->kebab [s]
@@ -43,24 +44,23 @@
m))
(defn is-admin? [id]
(println "role" id)
(= "admin" (:user/role id)))
(defn assert-admin [id]
(println "role" id)
(when-not (= "admin" (:user/role id))
(log/warn "user " id " not an admin!")
(throw-unauthorized)))
(defn can-see-client? [identity client]
(when (not client)
(println "WARNING - permission checking for null client"))
(log/warn "WARNING - permission checking for null client"))
(or (= "admin" (:user/role identity))
((set (map :db/id (:user/clients identity))) (:db/id client))
((set (map :db/id (:user/clients identity))) client)))
(defn assert-can-see-client [identity client]
(when-not (can-see-client? identity client)
(println "IDENTITY " identity " can not see company " client)
(log/warn "IDENTITY " identity " can not see company " client)
(throw-unauthorized)))
(defn limited-clients [id]