From fb651db26d603f4b591ba21308ec0210ed716949 Mon Sep 17 00:00:00 2001 From: Arne Brasseur Date: Tue, 27 Aug 2024 09:34:41 +0200 Subject: [PATCH] Fall back to discord username if no global_name is set, allow for missing email --- src/co/gaiwan/compass/routes/oauth.clj | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/co/gaiwan/compass/routes/oauth.clj b/src/co/gaiwan/compass/routes/oauth.clj index 878426e..b57d260 100644 --- a/src/co/gaiwan/compass/routes/oauth.clj +++ b/src/co/gaiwan/compass/routes/oauth.clj @@ -31,7 +31,7 @@ (defn user-tx [user-uuid {:keys [access_token refresh_token expires_in] :as body} - {:keys [id email global_name] :as user-info}] + {:keys [id email username global_name] :as user-info}] #_(def user-info user-info) (let [avatar-id (:avatar user-info) discord-avatar-url (when-not (str/blank? avatar-id) @@ -44,14 +44,15 @@ :exception e) discord-avatar-url)))] [(cond-> {:user/uuid user-uuid - :public-profile/name global_name + :public-profile/name (or global_name username) :discord/id id - :discord/email email :discord/access-token access_token :discord/refresh-token refresh_token :discord/expires-at (util/expires-in->instant expires_in)} avatar-url - (assoc :public-profile/avatar-url avatar-url))])) + (assoc :public-profile/avatar-url avatar-url) + email + (assoc :discord/email email))])) (defn GET-discord-callback [{:keys [query-params session]}] (let [{:strs [code state]} query-params