Add configuration option for registrations.

This commit is contained in:
Roger Braun 2017-09-15 14:39:32 +02:00
parent 50409326a8
commit c20530e708
3 changed files with 11 additions and 3 deletions

View file

@ -44,7 +44,8 @@
version: version, version: version,
name: "Pleroma", name: "Pleroma",
email: "example@example.com", email: "example@example.com",
limit: 5000 limit: 5000,
registrations_open: true
# Import environment specific config. This must remain at the bottom # Import environment specific config. This must remain at the bottom
# of this file so it overrides the configuration defined above. # of this file so it overrides the configuration defined above.

View file

@ -98,6 +98,9 @@ def user_fetcher(username) do
get "/statusnet/version", TwitterAPI.UtilController, :version get "/statusnet/version", TwitterAPI.UtilController, :version
end end
@instance Application.get_env(:pleroma, :instance)
@registrations_open Keyword.get(@instance, :registrations_open)
scope "/api", Pleroma.Web do scope "/api", Pleroma.Web do
pipe_through :api pipe_through :api
@ -110,7 +113,9 @@ def user_fetcher(username) do
get "/statuses/show/:id", TwitterAPI.Controller, :fetch_status get "/statuses/show/:id", TwitterAPI.Controller, :fetch_status
get "/statusnet/conversation/:id", TwitterAPI.Controller, :fetch_conversation get "/statusnet/conversation/:id", TwitterAPI.Controller, :fetch_conversation
post "/account/register", TwitterAPI.Controller, :register if @registrations_open do
post "/account/register", TwitterAPI.Controller, :register
end
get "/externalprofile/show", TwitterAPI.Controller, :external_profile get "/externalprofile/show", TwitterAPI.Controller, :external_profile
end end

View file

@ -16,6 +16,7 @@ def config(conn, _params) do
<name>#{Keyword.get(@instance, :name)}</name> <name>#{Keyword.get(@instance, :name)}</name>
<site>#{Web.base_url}</site> <site>#{Web.base_url}</site>
<textlimit>#{Keyword.get(@instance, :limit)}</textlimit> <textlimit>#{Keyword.get(@instance, :limit)}</textlimit>
<closed>#{!Keyword.get(@instance, :registrations_open)}</closed>
</site> </site>
</config> </config>
""" """
@ -27,7 +28,8 @@ def config(conn, _params) do
site: %{ site: %{
name: Keyword.get(@instance, :name), name: Keyword.get(@instance, :name),
server: Web.base_url, server: Web.base_url,
textlimit: Keyword.get(@instance, :limit) textlimit: Keyword.get(@instance, :limit),
closed: if(Keyword.get(@instance, :registrations_open), do: "0", else: "1")
} }
}) })
end end