[#2349] Made :skip_plug/2 prevent plug from being executed even if explicitly called. Refactoring. Tests.
This commit is contained in:
parent
bedf92e064
commit
bde1189c34
7 changed files with 140 additions and 6 deletions
|
|
@ -10,4 +10,8 @@ defmodule Pleroma.Plugs.AuthExpectedPlug do
|
|||
def call(conn, _) do
|
||||
put_private(conn, :auth_expected, true)
|
||||
end
|
||||
|
||||
def auth_expected?(conn) do
|
||||
conn.private[:auth_expected]
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -10,13 +10,13 @@ defmodule Pleroma.Plugs.OAuthScopesPlug do
|
|||
alias Pleroma.Plugs.EnsurePublicOrAuthenticatedPlug
|
||||
alias Pleroma.Plugs.PlugHelper
|
||||
|
||||
use Pleroma.Web, :plug
|
||||
|
||||
@behaviour Plug
|
||||
|
||||
def init(%{scopes: _} = options), do: options
|
||||
|
||||
def call(%Plug.Conn{assigns: assigns} = conn, %{scopes: scopes} = options) do
|
||||
conn = PlugHelper.append_to_called_plugs(conn, __MODULE__)
|
||||
|
||||
def perform(%Plug.Conn{assigns: assigns} = conn, %{scopes: scopes} = options) do
|
||||
op = options[:op] || :|
|
||||
token = assigns[:token]
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue