An IndieWeb engine for a self-hostable website. https://koype.net/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

setup.ex 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. # Koype: a IndieWeb-focused, single-tenant website engine for people.
  2. #
  3. # Copyright © 2019 Jacky Alciné <jacky.is@black.af>
  4. #
  5. # This file belongs to the Koype project.
  6. #
  7. # This program is free software: you can redistribute it and/or modify
  8. # it under the terms of the GNU Affero General Public License as published by
  9. # the Free Software Foundation, either version 3 of the License, or
  10. # (at your option) any later version.
  11. #
  12. # This program is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU Affero General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU Affero General Public License
  18. # along with this program. If not, see <https://www.gnu.org/licenses/>.
  19. defmodule Koype.Setup do
  20. @moduledoc """
  21. Provides logic for discovering and handling prerequistie configuration of Koype.
  22. """
  23. def complete?, do: !is_nil(Koype.Setting.get("setup_complete", nil))
  24. def complete!,
  25. do:
  26. Koype.Setting.set(
  27. "setup_complete",
  28. Calendar.DateTime.Format.rfc3339(Calendar.DateTime.now_utc(), 5)
  29. )
  30. def states do
  31. %{
  32. profile: Koype.Profile.complete?(),
  33. auth: !is_nil(Koype.Repo.OtpSecret.current())
  34. }
  35. end
  36. def state do
  37. Enum.reduce_while(states(), nil, fn {state, status}, acc ->
  38. if status, do: {:cont, acc}, else: {:halt, state}
  39. end)
  40. end
  41. end