implemented optional 'allow_registration' config, with first registered user being pre-confirmed Admin, registration unavailable after that point if allow_registration: :false
This commit is contained in:
parent
ea74a89078
commit
f27df8d676
22 changed files with 395 additions and 244 deletions
lib/shift73k
|
@ -108,6 +108,13 @@ defmodule Shift73k.Accounts do
|
|||
|
||||
"""
|
||||
def register_user(attrs) do
|
||||
# If attrs has atom keys, convert to string
|
||||
# If attrs don't include role, put default role
|
||||
attrs =
|
||||
attrs
|
||||
|> Map.new(fn {k, v} -> {to_string(k), v} end)
|
||||
|> Map.put_new("role", registration_role())
|
||||
|
||||
%User{}
|
||||
|> User.registration_changeset(attrs)
|
||||
|> Repo.insert()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue