forked from AkkomaGang/akkoma
Use changeset in user registration mix task.
This commit is contained in:
parent
03c6148bb3
commit
40706b4c4f
1 changed files with 5 additions and 3 deletions
|
@ -6,15 +6,17 @@ defmodule Mix.Tasks.RegisterUser do
|
||||||
@shortdoc "Register user"
|
@shortdoc "Register user"
|
||||||
def run([name, nickname, email, bio, password]) do
|
def run([name, nickname, email, bio, password]) do
|
||||||
ensure_started(Repo, [])
|
ensure_started(Repo, [])
|
||||||
user = %User{
|
|
||||||
|
params = %{
|
||||||
name: name,
|
name: name,
|
||||||
nickname: nickname,
|
nickname: nickname,
|
||||||
email: email,
|
email: email,
|
||||||
password_hash: Comeonin.Pbkdf2.hashpwsalt(password),
|
password: password,
|
||||||
|
password_confirmation: password,
|
||||||
bio: bio
|
bio: bio
|
||||||
}
|
}
|
||||||
|
|
||||||
user = %{ user | ap_id: User.ap_id(user), following: User.ap_followers(user) }
|
user = User.register_changeset(%User{}, params)
|
||||||
|
|
||||||
Repo.insert!(user)
|
Repo.insert!(user)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue