projects
/
akkoma
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
f45dc47
)
Add user registration mix task.
author
Roger Braun
<roger@rogerbraun.net>
Wed, 5 Apr 2017 10:27:25 +0000
(12:27 +0200)
committer
Roger Braun
<roger@rogerbraun.net>
Wed, 5 Apr 2017 10:27:25 +0000
(12:27 +0200)
lib/mix/tasks/register_user.ex
[new file with mode: 0644]
patch
|
blob
diff --git a/lib/mix/tasks/register_user.ex
b/lib/mix/tasks/register_user.ex
new file mode 100644
(file)
index 0000000..
e2f36c3
--- /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