Made auth customization be runtime-configurable.

This commit is contained in:
Ivan Tashkinov 2019-02-28 13:00:54 +03:00
parent e98d34e5fb
commit b6f915313f
3 changed files with 14 additions and 8 deletions

View File

@ -5,14 +5,16 @@
defmodule Pleroma.Web.Auth.DatabaseAuthenticator do
alias Pleroma.User
@implementation Pleroma.Config.get(
def implementation do
Pleroma.Config.get(
Pleroma.Web.Auth.DatabaseAuthenticator,
Pleroma.Web.Auth.PleromaDatabaseAuthenticator
)
end
@callback get_user(Plug.Conn.t()) :: {:ok, User.t()} | {:error, any()}
defdelegate get_user(plug), to: @implementation
def get_user(plug), do: implementation().get_user(plug)
@callback handle_error(Plug.Conn.t(), any()) :: any()
defdelegate handle_error(plug, error), to: @implementation
def handle_error(plug, error), do: implementation().handle_error(plug, error)
end

View File

@ -25,7 +25,7 @@ def authorize(conn, params) do
available_scopes = (app && app.scopes) || []
scopes = oauth_scopes(params, nil) || available_scopes
template = Application.get_env(:pleroma, :auth_template, "show.html")
template = Pleroma.Config.get(:auth_template, "show.html")
render(conn, template, %{
response_type: params["response_type"],

View File

@ -27,7 +27,11 @@ def controller do
import Pleroma.Web.Gettext
import Pleroma.Web.Router.Helpers
plug(:put_layout, Application.get_env(:pleroma, :app_layout, "app.html"))
plug(:set_put_layout)
defp set_put_layout(conn, _) do
put_layout(conn, Pleroma.Config.get(:app_layout, "app.html"))
end
end
end