X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;ds=sidebyside;f=lib%2Fpleroma%2Fplugs%2Foauth_scopes_plug.ex;h=b1a736d78ad2cf02727dd049769bc9937ae3f5c1;hb=9c672ecbb5d4477cd16d2139a2cb66d3923ac5c8;hp=a61582566ce6dfa6e7ae34ecc5a41f0ba4d02a78;hpb=f685cbd30940b3fd92a2f6c8a161729bc2ceaab6;p=akkoma diff --git a/lib/pleroma/plugs/oauth_scopes_plug.ex b/lib/pleroma/plugs/oauth_scopes_plug.ex index a61582566..b1a736d78 100644 --- a/lib/pleroma/plugs/oauth_scopes_plug.ex +++ b/lib/pleroma/plugs/oauth_scopes_plug.ex @@ -28,9 +28,7 @@ defmodule Pleroma.Plugs.OAuthScopesPlug do conn options[:fallback] == :proceed_unauthenticated -> - conn - |> assign(:user, nil) - |> assign(:token, nil) + drop_auth_info(conn) true -> missing_scopes = scopes -- matched_scopes @@ -46,7 +44,16 @@ defmodule Pleroma.Plugs.OAuthScopesPlug do end end - @doc "Filters descendants of supported scopes" + @doc "Drops authentication info from connection" + def drop_auth_info(conn) do + # To simplify debugging, setting a private variable on `conn` if auth info is dropped + conn + |> put_private(:authentication_ignored, true) + |> assign(:user, nil) + |> assign(:token, nil) + end + + @doc "Keeps those of `scopes` which are descendants of `supported_scopes`" def filter_descendants(scopes, supported_scopes) do Enum.filter( scopes,