akkoma/lib/mix/tasks/register_user.ex

22 lines
489 B
Elixir
Raw Normal View History

2017-04-05 10:27:25 +00:00
defmodule Mix.Tasks.RegisterUser do
use Mix.Task
import Mix.Ecto
alias Pleroma.{Repo, User}
@shortdoc "Register user"
def run([name, nickname, email, bio, password]) do
ensure_started(Repo, [])
user = %User{
name: name,
nickname: nickname,
email: email,
password_hash: Comeonin.Pbkdf2.hashpwsalt(password),
bio: bio
}
2017-04-14 15:29:27 +00:00
user = %{ user | ap_id: User.ap_id(user), following: User.ap_followers(user) }
2017-04-05 10:27:25 +00:00
Repo.insert!(user)
end
end