diff --git a/config/config.exs b/config/config.exs index c75f9ce..2f42758 100644 --- a/config/config.exs +++ b/config/config.exs @@ -11,6 +11,8 @@ config :lokal, ecto_repos: [Lokal.Repo], generators: [binary_id: true] +config :lokal, Lokal.Accounts, registration: System.get_env("REGISTRATION", "invite") + # Configures the endpoint config :lokal, LokalWeb.Endpoint, url: [scheme: "https", host: System.get_env("HOST") || "localhost", port: "443"], @@ -18,8 +20,7 @@ config :lokal, LokalWeb.Endpoint, secret_key_base: "KH59P0iZixX5gP/u+zkxxG8vAAj6vgt0YqnwEB5JP5K+E567SsqkCz69uWShjE7I", render_errors: [view: LokalWeb.ErrorView, accepts: ~w(html json), layout: false], pubsub_server: Lokal.PubSub, - live_view: [signing_salt: "zOLgd3lr"], - registration: System.get_env("REGISTRATION") || "invite" + live_view: [signing_salt: "zOLgd3lr"] config :lokal, Lokal.Application, automigrate: false diff --git a/config/runtime.exs b/config/runtime.exs index 8552a35..3367a21 100644 --- a/config/runtime.exs +++ b/config/runtime.exs @@ -42,6 +42,8 @@ config :lokal, Lokal.Repo, pool_size: String.to_integer(System.get_env("POOL_SIZE", "10")), socket_options: maybe_ipv6 +config :lokal, Lokal.Accounts, registration: System.get_env("REGISTRATION", "invite") + config :lokal, LokalWeb.Endpoint, url: [scheme: "https", host: host, port: 443], http: [ @@ -50,8 +52,7 @@ config :lokal, LokalWeb.Endpoint, ip: interface, port: String.to_integer(System.get_env("PORT", "4000")) ], - server: true, - registration: System.get_env("REGISTRATION", "invite") + server: true if config_env() == :prod do # The secret key base is used to sign/encrypt cookies and other secrets. diff --git a/lib/lokal/accounts.ex b/lib/lokal/accounts.ex index 4ae3f56..1f2eaba 100644 --- a/lib/lokal/accounts.ex +++ b/lib/lokal/accounts.ex @@ -384,7 +384,7 @@ defmodule Lokal.Accounts do """ @spec allow_registration?() :: boolean() def allow_registration? do - Application.get_env(:Lokal, LokalWeb.Endpoint)[:registration] == "public" or + Application.get_env(:lokal, Lokal.Accounts)[:registration] == "public" or list_users_by_role(:admin) |> Enum.empty?() end