Skip to content

Commit

Permalink
Fall back to discord username if no global_name is set, allow for mis…
Browse files Browse the repository at this point in the history
…sing email
  • Loading branch information
plexus committed Aug 27, 2024
1 parent e628416 commit fb651db
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/co/gaiwan/compass/routes/oauth.clj
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down

0 comments on commit fb651db

Please sign in to comment.