This repository has been archived on 2026-10-29. You can view files and clone it, but you cannot make any changes to its state, such as pushing and creating new issues, pull requests or comments.
GCLP/lp/lib/lp_web/controllers/git_controller.ex
2020-10-05 16:59:48 +07:00

25 lines
No EOL
885 B
Elixir

defmodule LpWeb.GitController do
@client_id Application.fetch_env!(:lp, :client_id)
@client_secret Application.fetch_env!(:lp, :client_secret)
use LpWeb, :controller
# @data "/priv/secret/github_credentials" |> File.stream! |> Enum.to_list
def index(conn, _params) do
render(conn, "git.html")
end
def show(conn, _params) do
html(conn,"")
end
def oauth(conn, _params) do
# render(conn, "oauth2.html")
redirect(conn, "git.html")
end
def github(conn, _params) do
authorize_url = Github.Oauth2.Client.authorize_url!(
# config: [client_id: Application.fetch_env!(:lp, :client_id), client_secret: Application.fetch_env!(:lp, :client_secret)],
config: [client_id: @client_id, client_secret: @client_secret],
scope: "user:email"
)
conn |> redirect(external: authorize_url)
end
end