fix some bugs n stuff
This commit is contained in:
parent
b925726977
commit
d7559647e2
7 changed files with 90 additions and 21 deletions
|
|
@ -1,4 +1,5 @@
|
|||
defmodule ZoeyscomputerWeb.Router do
|
||||
alias ZoeyscomputerWeb.DiscordPlug
|
||||
use ZoeyscomputerWeb, :router
|
||||
|
||||
import ZoeyscomputerWeb.UserAuth
|
||||
|
|
@ -17,6 +18,10 @@ defmodule ZoeyscomputerWeb.Router do
|
|||
plug ZoeyscomputerWeb.Plugs.ApiAuthentication
|
||||
end
|
||||
|
||||
pipeline :discord do
|
||||
plug DiscordPlug
|
||||
end
|
||||
|
||||
pipeline :api do
|
||||
plug :accepts, ["json"]
|
||||
end
|
||||
|
|
@ -80,6 +85,8 @@ defmodule ZoeyscomputerWeb.Router do
|
|||
live "/images/new", ImageLive.Index, :new
|
||||
live "/images/:id/edit", ImageLive.Index, :edit
|
||||
|
||||
live "/images", ImageLive.Index, :index
|
||||
|
||||
live "/images/:id/show/edit", ImageLive.Show, :edit
|
||||
|
||||
live "/api-keys", ApiKeyLive.Index, :index
|
||||
|
|
@ -101,9 +108,28 @@ defmodule ZoeyscomputerWeb.Router do
|
|||
live "/users/confirm/:token", UserConfirmationLive, :edit
|
||||
live "/users/confirm", UserConfirmationInstructionsLive, :new
|
||||
live "/", HomeLive, :index
|
||||
end
|
||||
end
|
||||
|
||||
live "/images", ImageLive.Index, :index
|
||||
live "/images/:id", ImageLive.Show, :show
|
||||
scope "/", ZoeyscomputerWeb do
|
||||
pipe_through :check_discord
|
||||
live "/images/:id", ImageController, :show
|
||||
end
|
||||
|
||||
def check_discord(conn, _opts) do
|
||||
case get_req_header(conn, "user-agent") do
|
||||
["Discord" <> _rest | _] ->
|
||||
conn
|
||||
|> put_private(:phoenix_pipeline, {:doscord, []})
|
||||
|> DiscordPlug.call([])
|
||||
|
||||
["Discord-Bot/" <> _rest | _] ->
|
||||
conn
|
||||
|> put_private(:phoenix_pipeline, {:discord, []})
|
||||
|> DiscordPlug.call([])
|
||||
|
||||
_ ->
|
||||
conn |> put_private(:phoenix_pipeline, {:browser, []})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue