Fakultas Ilmu Komputer UI

Commit 0398ef3b authored by Muhammad Rafif Elfazri's avatar Muhammad Rafif Elfazri
Browse files

Merge branch 'deploy-runtime' into 'master'

Deploy runtime

See merge request !9
parents d2fc5e82 7d8c2f24
......@@ -4,6 +4,4 @@ DATABASE_USER=postgres
DATABASE_HOST=db
DATABASE_URL=ecto://postgres:postgres@db/postgres
PORT=4000
HOSTNAME=localhost
POSTGRES_PASSWORD=postgres
LANG=en_US.UTF-8s
\ No newline at end of file
# PROXY="http://sample.com:8080"
\ No newline at end of file
......@@ -42,6 +42,9 @@ config :diskuy, DiskuyWeb.Auth.Guardian,
issuer: "diskuy",
secret_key: guardian_secret_key_base
config :diskuy, DiskuyWeb.Auth.GoogleAuth,
proxy: System.get_env("PROXY")
# ## Using releases (Elixir v1.9+)
#
# If you are doing OTP releases, you need to instruct Phoenix
......
......@@ -5,14 +5,23 @@ defmodule DiskuyWeb.Auth.GoogleAuth do
@google_user_profile "https://www.googleapis.com/oauth2/v3/userinfo"
@spec get_user_profile(String.t) :: String.t
def get_user_profile(token) do
"#{@google_user_profile}?access_token=#{token}"
|> HTTPoison.get()
|> handle_get_proxy()
|> parse_body_response()
end
@spec parse_body_response({atom, String.t}) :: String.t
defp handle_get_proxy(url) do
case Application.get_env(:diskuy, :proxy) do
nil ->
HTTPoison.get(url)
proxy ->
HTTPoison.get(url, [], [{:proxy, proxy}])
end
end
def parse_body_response({:error, err}), do: {:error, err}
def parse_body_response({:ok, response}) do
body = Map.get(response, :body)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment