X-Git-Url: https://git.squeep.com/?a=blobdiff_plain;f=lib%2Fpleroma%2Fweb.ex;h=5761e3b385c61d9b7adb5a6d538b4cb2d52e361c;hb=3e0a5851e528135a04ca8f9ab59607ecc3ba42d9;hp=0a4c98e4778c4f59d1f4249b7e8590943b94bdc5;hpb=6b87dfad5de161cf2bef43d02ff89debcee84dd3;p=akkoma diff --git a/lib/pleroma/web.ex b/lib/pleroma/web.ex index 0a4c98e47..5761e3b38 100644 --- a/lib/pleroma/web.ex +++ b/lib/pleroma/web.ex @@ -28,8 +28,6 @@ defmodule Pleroma.Web do alias Pleroma.Web.Plugs.OAuthScopesPlug alias Pleroma.Web.Plugs.PlugHelper - @mix_env Mix.env() - def controller do quote do use Phoenix.Controller, namespace: Pleroma.Web @@ -37,9 +35,10 @@ defmodule Pleroma.Web do import Plug.Conn import Pleroma.Web.Gettext - import Pleroma.Web.Router.Helpers import Pleroma.Web.TranslationHelpers + alias Pleroma.Web.Router.Helpers, as: Routes + plug(:set_put_layout) defp set_put_layout(conn, _) do @@ -63,6 +62,14 @@ defmodule Pleroma.Web do ) end + defp skip_auth(conn, _) do + skip_plug(conn, [OAuthScopesPlug, EnsurePublicOrAuthenticatedPlug]) + end + + defp skip_public_check(conn, _) do + skip_plug(conn, EnsurePublicOrAuthenticatedPlug) + end + # Executed just before actual controller action, invokes before-action hooks (callbacks) defp action(conn, params) do with %{halted: false} = conn <- @@ -133,7 +140,8 @@ defmodule Pleroma.Web do import Pleroma.Web.ErrorHelpers import Pleroma.Web.Gettext - import Pleroma.Web.Router.Helpers + + alias Pleroma.Web.Router.Helpers, as: Routes require Logger @@ -231,23 +239,4 @@ defmodule Pleroma.Web do defmacro __using__(which) when is_atom(which) do apply(__MODULE__, which, []) end - - def base_url do - Pleroma.Web.Endpoint.url() - end - - def get_api_routes do - Pleroma.Web.Router.__routes__() - |> Enum.reject(fn - r -> - r.plug == Pleroma.Web.Fallback.RedirectController or - String.starts_with?(r.path, "/#{@mix_env}") - end) - |> Enum.map(fn r -> - r.path - |> String.split("/", trim: true) - |> List.first() - end) - |> Enum.uniq() - end end