summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElizabeth Hunt <elizabeth.hunt@simponic.xyz>2023-09-13 19:47:50 -0600
committerElizabeth Hunt <elizabeth.hunt@simponic.xyz>2023-09-13 19:47:50 -0600
commit87bd117289f6824a61fd30d7633d07d305435924 (patch)
tree1cb6131adf12e2a48723f80398d05db1df7296e9
parent8f722fde7222d5a664753723b6fbc8bc69dadb06 (diff)
downloadchessh-87bd117289f6824a61fd30d7633d07d305435924.tar.gz
chessh-87bd117289f6824a61fd30d7633d07d305435924.zip
log setup web
-rw-r--r--lib/chessh/web/web.ex22
1 files changed, 15 insertions, 7 deletions
diff --git a/lib/chessh/web/web.ex b/lib/chessh/web/web.ex
index 2e6e8b0..5835ff2 100644
--- a/lib/chessh/web/web.ex
+++ b/lib/chessh/web/web.ex
@@ -26,17 +26,25 @@ defmodule Chessh.Web.Endpoint do
redirect_uri
] = get_discord_configs()
+ Logger.warn(
+ inspect(
+ {String.to_charlist(discord_login_url), [], ~c"application/x-www-form-urlencoded",
+ ~c"scope=#{discord_scope}&client_id=#{client_id}&client_secret=#{client_secret}&code=#{req_token}&grant_type=authorization_code&redirect_uri=#{redirect_uri}"}
+ )
+ )
+
resp =
case conn.params do
%{"code" => req_token} ->
case :httpc.request(
:post,
- {String.to_charlist(discord_login_url), [], 'application/x-www-form-urlencoded',
- 'scope=#{discord_scope}&client_id=#{client_id}&client_secret=#{client_secret}&code=#{req_token}&grant_type=authorization_code&redirect_uri=#{redirect_uri}'},
+ {String.to_charlist(discord_login_url), [],
+ ~c"application/x-www-form-urlencoded",
+ ~c"scope=#{discord_scope}&client_id=#{client_id}&client_secret=#{client_secret}&code=#{req_token}&grant_type=authorization_code&redirect_uri=#{redirect_uri}"},
[],
[]
) do
- {:ok, {{_, 200, 'OK'}, _, resp}} ->
+ {:ok, {{_, 200, ~c"OK"}, _, resp}} ->
Jason.decode!(String.Chars.to_string(resp))
end
end
@@ -442,7 +450,7 @@ defmodule Chessh.Web.Endpoint do
conn
|> put_resp_cookie("jwt", token)
|> put_resp_header("location", client_redirect_location)
- |> send_resp(301, '')
+ |> send_resp(301, ~c"")
_ ->
conn
@@ -458,13 +466,13 @@ defmodule Chessh.Web.Endpoint do
:get,
{String.to_charlist(discord_user_api_url),
[
- {'Authorization', String.to_charlist("Bearer #{access_token}")},
- {'User-Agent', discord_user_agent}
+ {~c"Authorization", String.to_charlist("Bearer #{access_token}")},
+ {~c"User-Agent", discord_user_agent}
]},
[],
[]
) do
- {:ok, {{_, 200, 'OK'}, _, user_details}} ->
+ {:ok, {{_, 200, ~c"OK"}, _, user_details}} ->
%{"username" => username, "discriminator" => discriminator, "id" => discord_id} =
Jason.decode!(String.Chars.to_string(user_details))