centralize allow registration check logic

This commit is contained in:
2021-09-10 00:18:15 -04:00
committed by oliviasculley
parent 707b7215e7
commit b1c4d824bc
3 changed files with 23 additions and 4 deletions

View File

@ -238,6 +238,14 @@ defmodule Cannery.Accounts do
:ok
end
@doc """
Returns a boolean if registration is allowed or not
"""
def allow_registration?() do
Application.get_env(:cannery, CanneryWeb.Endpoint)[:registration] == "public" or
list_users_by_role(:admin) |> Enum.empty?()
end
## Confirmation
@doc """