[#1427] Fixed :admin option handling in OAuthScopesPlug, added tests.

This commit is contained in:
Ivan Tashkinov 2019-12-11 11:42:02 +03:00
commit 3920244be5
3 changed files with 56 additions and 10 deletions

View file

@ -68,8 +68,13 @@ defmodule Pleroma.Config do
def enforce_oauth_admin_scope_usage?, do: !!get([:auth, :enforce_oauth_admin_scope_usage])
def oauth_admin_scopes(scope) do
["admin:#{scope}"] ++
if enforce_oauth_admin_scope_usage?(), do: [], else: [scope]
def oauth_admin_scopes(scopes) when is_list(scopes) do
Enum.flat_map(
scopes,
fn scope ->
["admin:#{scope}"] ++
if enforce_oauth_admin_scope_usage?(), do: [], else: [scope]
end
)
end
end