mirror of
https://github.com/mgerb/classic-wow-forums
synced 2026-01-12 01:52:49 +00:00
thread update/insert changeset fixed - auth permissions done
This commit is contained in:
@@ -3,7 +3,7 @@ defmodule MyAppWeb.BattleNetController do
|
||||
alias MyAppWeb.Response
|
||||
alias MyApp.BattleNet
|
||||
alias MyApp.Data
|
||||
alias MyApp.JWT
|
||||
alias MyApp.Guardian.Auth
|
||||
|
||||
# https://us.battle.net/oauth/authorize?redirect_uri=https://localhost/api/battlenet/authorize&scope=wow.profile&client_id=vxqv32fddxsy6cmk6259amtymbuzmfrq&response_type=code
|
||||
|
||||
@@ -14,7 +14,7 @@ defmodule MyAppWeb.BattleNetController do
|
||||
|> BattleNet.Auth.get_access_token
|
||||
|> BattleNet.User.get_user
|
||||
|> Data.User.upsert_user
|
||||
|> JWT.add_jwt
|
||||
|> Auth.Token.add_token_and_map_claims
|
||||
|> Response.put_resp
|
||||
|
||||
conn
|
||||
|
||||
@@ -3,9 +3,7 @@ defmodule MyAppWeb.UserController do
|
||||
alias MyAppWeb.Response
|
||||
|
||||
@spec index(map, map) :: any
|
||||
def index(conn, params) do
|
||||
IO.inspect(conn)
|
||||
IO.inspect(params)
|
||||
def index(conn, _params) do
|
||||
conn
|
||||
|> Response.json("Auth works!")
|
||||
end
|
||||
|
||||
@@ -1,13 +1,21 @@
|
||||
defmodule MyAppWeb.Router do
|
||||
use MyAppWeb, :router
|
||||
alias MyApp.Guardian.AuthPipeline
|
||||
alias MyApp.Guardian.Auth
|
||||
|
||||
pipeline :api do
|
||||
plug :accepts, ["json"]
|
||||
end
|
||||
|
||||
pipeline :api_auth do
|
||||
plug AuthPipeline.JSON
|
||||
pipeline :user_auth do
|
||||
plug Auth.Pipeline.User
|
||||
end
|
||||
|
||||
pipeline :mod_auth do
|
||||
plug Auth.Pipeline.Mod
|
||||
end
|
||||
|
||||
pipeline :admin_auth do
|
||||
plug Auth.Pipeline.Admin
|
||||
end
|
||||
|
||||
# Other scopes may use custom stacks.
|
||||
@@ -17,26 +25,26 @@ defmodule MyAppWeb.Router do
|
||||
scope "/battlenet" do
|
||||
get "/authorize", BattleNetController, :authorize
|
||||
|
||||
pipe_through [:api_auth]
|
||||
pipe_through [:user_auth]
|
||||
get "/characters", BattleNetController, :characters
|
||||
end
|
||||
|
||||
scope "/user" do
|
||||
# authenticated routes
|
||||
pipe_through [:api_auth]
|
||||
pipe_through [:user_auth]
|
||||
get "/", UserController, :index
|
||||
end
|
||||
|
||||
scope "/thread" do
|
||||
# authenticated routes
|
||||
pipe_through [:api_auth]
|
||||
pipe_through [:user_auth]
|
||||
post "/", ThreadController, :insert
|
||||
put "/", ThreadController, :update
|
||||
end
|
||||
|
||||
scope "reply" do
|
||||
scope "/reply" do
|
||||
# authenticated routes
|
||||
pipe_through [:api_auth]
|
||||
pipe_through [:user_auth]
|
||||
post "/", ReplyController, :insert
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user