revamped logging!
This commit is contained in:
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user