From aa5a1f30f990eca3559dacd6c75b8adc75e5e61b Mon Sep 17 00:00:00 2001 From: shibao Date: Sat, 18 Mar 2023 01:31:56 -0400 Subject: [PATCH] add Accounts.registration_mode/0 --- lib/memex/accounts.ex | 11 +++++++++++ lib/memex_web/live/home_live.html.heex | 6 +++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/lib/memex/accounts.ex b/lib/memex/accounts.ex index 40a8a3c..56bcf7b 100644 --- a/lib/memex/accounts.ex +++ b/lib/memex/accounts.ex @@ -389,6 +389,17 @@ defmodule Memex.Accounts do list_users_by_role(:admin) |> Enum.empty?() end + @doc """ + Returns an atom representing the current configured registration mode + """ + @spec registration_mode() :: :public | :invite_only + def registration_mode do + case Application.get_env(:memex, Memex.Accounts)[:registration] do + "public" -> :public + _other -> :invite_only + end + end + @doc """ Checks if user is an admin diff --git a/lib/memex_web/live/home_live.html.heex b/lib/memex_web/live/home_live.html.heex index c304391..e0f199a 100644 --- a/lib/memex_web/live/home_live.html.heex +++ b/lib/memex_web/live/home_live.html.heex @@ -100,9 +100,9 @@
  • <%= gettext("registration:") %>

    - <%= case Application.get_env(:memex, Memex.Accounts)[:registration] do - "public" -> gettext("public signups") - _ -> gettext("invite only") + <%= case Accounts.registration_mode() do + :public -> gettext("public signups") + :invite_only -> gettext("invite only") end %>