Merge branch 'runtime-router' into 'develop'
Runtime configured router See merge request pleroma/pleroma!426
This commit is contained in:
commit
0f3e78addb
11 changed files with 183 additions and 35 deletions
|
|
@ -11,6 +11,7 @@ defmodule Pleroma.Web.TwitterAPI.Controller do
|
|||
|
||||
require Logger
|
||||
|
||||
plug(:only_if_public_instance when action in [:public_timeline, :public_and_external_timeline])
|
||||
action_fallback(:errors)
|
||||
|
||||
def verify_credentials(%{assigns: %{user: user}} = conn, _params) do
|
||||
|
|
@ -518,6 +519,18 @@ defmodule Pleroma.Web.TwitterAPI.Controller do
|
|||
json_reply(conn, 403, json)
|
||||
end
|
||||
|
||||
def only_if_public_instance(conn = %{conn: %{assigns: %{user: _user}}}, _), do: conn
|
||||
|
||||
def only_if_public_instance(conn, _) do
|
||||
if Keyword.get(Application.get_env(:pleroma, :instance), :public) do
|
||||
conn
|
||||
else
|
||||
conn
|
||||
|> forbidden_json_reply("Invalid credentials.")
|
||||
|> halt()
|
||||
end
|
||||
end
|
||||
|
||||
defp error_json(conn, error_message) do
|
||||
%{"error" => error_message, "request" => conn.request_path} |> Jason.encode!()
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue