diff --git a/web/panettone/src/authentication.lisp b/web/panettone/src/authentication.lisp index 205102575..50befbc7a 100644 --- a/web/panettone/src/authentication.lisp +++ b/web/panettone/src/authentication.lisp @@ -79,12 +79,18 @@ and a retry" (defun find-user-by-dn (dn) (with-ldap () - (progn - (ldap:search *ldap* `(= objectClass organizationalPerson) - :base dn - :scope 'ldap:base) - (when-let ((ldap-entry (ldap:next-search-result *ldap*))) - (ldap-entry->user ldap-entry))))) + (let ((have-results + (handler-case + (ldap:search *ldap* `(= objectClass organizationalPerson) + :base dn + :scope 'ldap:base) + ; catch ldap-errors generated by trivial-ldap:parse-ldap-message + ; since this is thrown on conditions which we don't want this + ; function to fail like when there are no search results + (trivial-ldap:ldap-error (e) nil)))) + (when have-results + (when-let ((ldap-entry (ldap:next-search-result *ldap*))) + (ldap-entry->user ldap-entry)))))) (comment (find-user-by-dn "cn=glittershark,ou=users,dc=tvl,dc=fyi") diff --git a/web/panettone/src/panettone.lisp b/web/panettone/src/panettone.lisp index e090f11ac..6e4331232 100644 --- a/web/panettone/src/panettone.lisp +++ b/web/panettone/src/panettone.lisp @@ -90,6 +90,10 @@ (defun author (object) (find-user-by-dn (author-dn object))) +(defun displayname-if-known (user) + (or (when user (displayname user)) + "unknown")) + (defmacro render ((&key (footer t) (header t)) @@ -171,11 +175,8 @@ (:span :class "created-by-at" "Opened by " (:span :class "username" - (who:esc - (or - (when-let ((author (author issue))) - (displayname author)) - "someone"))) + (who:esc (displayname-if-known + (author issue)))) " at " (:span :class "timestamp" (who:esc @@ -293,7 +294,8 @@ (:p :class "comment-info" (:span :class "username" - (who:esc (displayname (author comment))) + (who:esc + (displayname-if-known (author comment))) " at " (:a :href (concatenate 'string "#" fragment) (who:esc (format-dottime (created-at comment)))))))))) @@ -304,7 +306,7 @@ (:li :class "event" :id - (who:esc (displayname user)) + (who:esc (displayname-if-known user)) (if (string= (field event) "STATUS") (who:htm (who:esc