2017-04-05 06:27:25 -04:00
|
|
|
defmodule Mix.Tasks.RegisterUser do
|
2018-07-12 19:02:18 -04:00
|
|
|
@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``
|
|
|
|
"""
|
|
|
|
|
2017-04-05 06:27:25 -04:00
|
|
|
use Mix.Task
|
|
|
|
alias Pleroma.{Repo, User}
|
|
|
|
|
|
|
|
@shortdoc "Register user"
|
|
|
|
def run([name, nickname, email, bio, password]) do
|
2018-04-10 15:05:53 -04:00
|
|
|
Mix.Task.run("app.start")
|
2017-04-15 10:42:02 -04:00
|
|
|
|
|
|
|
params = %{
|
2017-04-05 06:27:25 -04:00
|
|
|
name: name,
|
|
|
|
nickname: nickname,
|
|
|
|
email: email,
|
2017-04-15 10:42:02 -04:00
|
|
|
password: password,
|
|
|
|
password_confirmation: password,
|
2017-04-05 06:27:25 -04:00
|
|
|
bio: bio
|
|
|
|
}
|
|
|
|
|
2017-04-15 10:42:02 -04:00
|
|
|
user = User.register_changeset(%User{}, params)
|
2017-04-05 06:27:25 -04:00
|
|
|
|
|
|
|
Repo.insert!(user)
|
|
|
|
end
|
|
|
|
end
|