akkoma/lib/mix/tasks/register_user.ex
Haelwenn (lanodan) Monnier e1814bb322
Document mix tasks
2018-11-10 13:09:37 +01:00

30 lines
714 B
Elixir

defmodule Mix.Tasks.RegisterUser do
@moduledoc """
Manually register a local user
Usage: ``mix register_user <name> <nickname> <email> <bio> <password>``
Example: ``mix register_user 仮面の告白 lain lain@example.org "blushy-crushy fediverse idol + pleroma dev" pleaseDontHeckLain``
"""
use Mix.Task
alias Pleroma.{Repo, User}
@shortdoc "Register user"
def run([name, nickname, email, bio, password]) do
Mix.Task.run("app.start")
params = %{
name: name,
nickname: nickname,
email: email,
password: password,
password_confirmation: password,
bio: bio
}
user = User.register_changeset(%User{}, params)
Repo.insert!(user)
end
end