Made auth customization be runtime-configurable.
authorIvan Tashkinov <ivantashkinov@gmail.com>
Thu, 28 Feb 2019 10:00:54 +0000 (13:00 +0300)
committerIvan Tashkinov <ivantashkinov@gmail.com>
Thu, 28 Feb 2019 10:00:54 +0000 (13:00 +0300)
lib/pleroma/web/auth/database_authenticator.ex
lib/pleroma/web/oauth/oauth_controller.ex
lib/pleroma/web/web.ex

index 02a16b634540a3c15e6c5897a22d68d363c1edac..e78068b03bb65417cfa43a5c8ed37bd9147cac8b 100644 (file)
@@ -5,14 +5,16 @@
 defmodule Pleroma.Web.Auth.DatabaseAuthenticator do
   alias Pleroma.User
 
-  @implementation Pleroma.Config.get(
-                    Pleroma.Web.Auth.DatabaseAuthenticator,
-                    Pleroma.Web.Auth.PleromaDatabaseAuthenticator
-                  )
+  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
index 02c0babd24080f75bc936f0a48aa10b8c1b17c81..5c2b0507c9a0c8c5dc48fb0dff643986c22d55b8 100644 (file)
@@ -25,7 +25,7 @@ defmodule Pleroma.Web.OAuth.OAuthController 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"],
index 4bf07a6ef6eba6d6207a70532ec59507a125dc96..66813e4ddaffa5ad1fd4f807047e639c86a29cc0 100644 (file)
@@ -27,7 +27,11 @@ defmodule Pleroma.Web 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