postland/lib/postland.ex

35 lines
760 B
Elixir
Raw Normal View History

2024-09-20 19:30:46 +00:00
defmodule Postland do
@moduledoc """
Postland keeps the contexts that define your domain
and business logic.
Contexts are also responsible for managing your data, regardless
if it comes from the database, an external API or others.
"""
alias Postland.Accounts
2024-09-21 22:10:43 +00:00
def temporary_password() do
:crypto.strong_rand_bytes(12) |> Base.encode64()
end
def on_boot_setup() do
if !setup?() do
attrs = %{
username: "welcome",
password: temporary_password()
}
{:ok, _user} = Accounts.register_user(attrs)
IO.puts(
"Your temporary username is #{attrs.username} and your temporary password is #{attrs.password}"
)
end
end
2024-09-20 19:30:46 +00:00
def setup?() do
Accounts.solo_user() != nil
end
end