summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.env.example1
-rw-r--r--config/runtime.exs4
-rw-r--r--lib/chessh/web/web.ex4
3 files changed, 6 insertions, 3 deletions
diff --git a/.env.example b/.env.example
index 20ddef1..f27a541 100644
--- a/.env.example
+++ b/.env.example
@@ -12,6 +12,7 @@ REACT_APP_DISCORD_INVITE=https://discord.gg/ajsdlkfjaskldjf
REACT_APP_DISCORD_OAUTH=https://discord.com/api/oauth2/authorize?client_id=CLIENT_ID&redirect_uri=FRONTEND_REDIRECT_PORT_FROM_BELOW&response_type=code&scope=identify
CLIENT_REDIRECT_AFTER_OAUTH=http://127.0.0.1:3000/auth-successful
+SERVER_REDIRECT_URI=http://127.0.0.1:3000/api/oauth/redirect
DISCORD_CLIENT_ID=
DISCORD_CLIENT_SECRET=
diff --git a/config/runtime.exs b/config/runtime.exs
index 2be7431..ebdb2cc 100644
--- a/config/runtime.exs
+++ b/config/runtime.exs
@@ -8,7 +8,9 @@ config :chessh, Web,
discord_client_secret: System.get_env("DISCORD_CLIENT_SECRET"),
discord_user_agent: System.get_env("DISCORD_USER_AGENT"),
client_redirect_after_successful_sign_in:
- System.get_env("CLIENT_REDIRECT_AFTER_OAUTH", "http://127.0.0.1:3000/oauth-successfule"),
+ System.get_env("CLIENT_REDIRECT_AFTER_OAUTH", "http://127.0.0.1:3000/auth-successful"),
+ server_redirect_uri:
+ System.get_env("SERVER_REDIRECT_URI", "http://127.0.0.1:3000/api/oauth/redirect"),
port: String.to_integer(System.get_env("WEB_PORT", "8080"))
config :joken,
diff --git a/lib/chessh/web/web.ex b/lib/chessh/web/web.ex
index 067a27c..7b2f696 100644
--- a/lib/chessh/web/web.ex
+++ b/lib/chessh/web/web.ex
@@ -32,7 +32,7 @@ defmodule Chessh.Web.Endpoint do
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}'},
+ 'scope=#{discord_scope}&client_id=#{client_id}&client_secret=#{client_secret}&code=#{req_token}&grant_type=authorization_code&redirect_uri=http://127.0.0.1:3000/api/oauth/redirect'},
[],
[]
) do
@@ -214,7 +214,7 @@ defmodule Chessh.Web.Endpoint do
:discord_client_secret,
:discord_user_api_url,
:discord_user_agent,
- :client_redirect_after_successful_sign_in
+ :server_redirect_uri
],
fn key -> Application.get_env(:chessh, Web)[key] end
)