Add discriminator to username when oauth'd

This commit is contained in:
Elizabeth Hunt 2023-01-31 20:59:01 -07:00
parent e4c387d7a5
commit 800d479863
Signed by: simponic
GPG Key ID: 52B3774857EB24B1

View File

@ -267,11 +267,12 @@ defmodule Chessh.Web.Endpoint do
[]
) do
{:ok, {{_, 200, 'OK'}, _, user_details}} ->
%{"username" => username, "id" => discord_id} =
%{"username" => username, "discriminator" => discriminator, "id" => discord_id} =
Jason.decode!(String.Chars.to_string(user_details))
%Player{id: id} =
Repo.insert!(%Player{discord_id: discord_id, username: username},
Repo.insert!(
%Player{discord_id: discord_id, username: username <> "#" <> discriminator},
on_conflict: [set: [discord_id: discord_id]],
conflict_target: :discord_id
)