Skip to content

Instantly share code, notes, and snippets.

@xudifsd
Created January 3, 2015 05:27
Show Gist options
  • Save xudifsd/70b01fb318d7fd970269 to your computer and use it in GitHub Desktop.
Save xudifsd/70b01fb318d7fd970269 to your computer and use it in GitHub Desktop.
ACL checker before optimization
(defn self-is-active?
[{{:keys [uid]} :params :as req}]
(when-not (nil? uid)
(let [user-id (u/->int uid)
user (users/get-user-by-id user-id)]
(when-not (nil? user)
(not (:inactive user))))))
(defn self-belongs-to-team?
[{{:keys [uid subdomain]} :params :as req}]
(when-not (nil? uid)
(let [user-id (u/->int uid)
user (users/get-user-by-id user-id)
team (teams/get-team-by-subdomain subdomain)]
(when-not (some nil? [user team])
(= (:team_id user) (:id team))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment