Skip to content

Commit 8dad6a4

Browse files
author
Brad Peterson
committed
Use authorized to check if agent
- Works for admins too (derived from agents) - Works when the request map doesn't have nil in the authorizations map
1 parent 33605a4 commit 8dad6a4

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/chatb0x/websockets.clj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
(:require [org.httpkit.server :refer [with-channel on-close on-receive send!]]
33
[chatb0x.user :refer :all]
44
[cheshire.core :refer [generate-string]]
5+
[cemerick.friend :as friend]
56
[digest :refer [md5]]
67
[clojure.string :as str]))
78

@@ -114,7 +115,7 @@
114115
(with-channel req channel
115116
;; CONNECT
116117
(println req)
117-
(if (contains? (get-in req [:session :cemerick.friend/identity :authentications nil :roles]) :chatb0x.user/agent)
118+
(if (friend/authorized? #{:chatb0x.user/agent} (friend/identity req))
118119
(do (println "Agent connected: " channel) ;; Agent
119120
(swap! ds-clients assoc channel {:name nil :gravatar-url (calc-gravatar (get-in req [:session :cemerick.friend/identity :authentications nil :username])) :room nil}) ;; Add to ds-clients
120121
(swap! ds-agents assoc channel {}))

0 commit comments

Comments
 (0)