Add user registration mix task.
This commit is contained in:
parent
f45dc475c7
commit
567ec494c5
1 changed files with 21 additions and 0 deletions
21
lib/mix/tasks/register_user.ex
Normal file
21
lib/mix/tasks/register_user.ex
Normal file
|
@ -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
|
Loading…
Reference in a new issue