mirror of
https://github.com/mgerb/classic-wow-forums
synced 2026-01-12 01:52:49 +00:00
init
This commit is contained in:
20
lib/myapp_web/controllers/battle_net_controller.ex
Normal file
20
lib/myapp_web/controllers/battle_net_controller.ex
Normal file
@@ -0,0 +1,20 @@
|
||||
defmodule MyAppWeb.BattleNetController do
|
||||
use MyAppWeb, :controller
|
||||
alias MyAppWeb.Response
|
||||
alias MyApp.BattleNet.Auth
|
||||
|
||||
# https://us.battle.net/oauth/authorize?redirect_uri=https://localhost/api/battlenet/authorize&scope=wow.profile&client_id=vxqv32fddxsy6cmk6259amtymbuzmfrq&response_type=code
|
||||
|
||||
def authorize(conn, %{"code" => code}) when not is_nil(code) do
|
||||
|
||||
{output, status} = case Auth.get_token(code) do
|
||||
{:ok, token} -> {token, 200}
|
||||
{:error, err} -> {err, 400}
|
||||
end
|
||||
|
||||
conn
|
||||
|>put_status(status)
|
||||
|>Response.json(output)
|
||||
end
|
||||
|
||||
end
|
||||
12
lib/myapp_web/controllers/user_controller.ex
Normal file
12
lib/myapp_web/controllers/user_controller.ex
Normal file
@@ -0,0 +1,12 @@
|
||||
defmodule MyAppWeb.UserController do
|
||||
use MyAppWeb, :controller
|
||||
alias MyAppWeb.Response
|
||||
|
||||
def index(conn, params) do
|
||||
IO.inspect(conn)
|
||||
IO.inspect(params)
|
||||
conn
|
||||
|> Response.json("Auth works!")
|
||||
end
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user