From 567ec494c523ded79c69f4d1bb0be9e51ca09837 Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Wed, 5 Apr 2017 12:27:25 +0200 Subject: [PATCH] Add user registration mix task. --- lib/mix/tasks/register_user.ex | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 lib/mix/tasks/register_user.ex diff --git a/lib/mix/tasks/register_user.ex b/lib/mix/tasks/register_user.ex new file mode 100644 index 000000000..e2f36c34c --- /dev/null +++ b/lib/mix/tasks/register_user.ex @@ -0,0 +1,21 @@ +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 + } + + user = %{ user | ap_id: User.ap_id(user) } + + Repo.insert!(user) + end +end -- 2.45.2