Skip to content

Commit

Permalink
On allow login for users that have at least one role
Browse files Browse the repository at this point in the history
  • Loading branch information
egli committed Oct 16, 2024
1 parent 655e67c commit 9715d52
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/clj/mdr2/ldap.clj
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@
set)]
(assoc user :roles roles)))

(defn- not-empty-roles
"Return the given `user` if it has any roles, otherwise return nil"
[{:keys [roles] :as user}]
(when (not-empty roles) user))

(defn authenticate [username password & [attributes]]
(let [conn (ldap/get-connection ldap-pool)
qualified-name (str "uid=" username ",cn=users,cn=accounts,dc=sbszh,dc=ch")]
Expand All @@ -54,5 +59,6 @@
:attributes (or attributes [])})
first
add-roles
(select-keys [:uid :mail :initials :givenName :displayName :telephoneNumber :roles])))
(select-keys [:uid :mail :initials :givenName :displayName :telephoneNumber :roles])
not-empty-roles)) ;; only return users that have a role
(finally (ldap/release-connection ldap-pool conn)))))

0 comments on commit 9715d52

Please sign in to comment.