From 40706b4c4fe4ae29bf01ef13bc3e79318773d66f Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Sat, 15 Apr 2017 16:42:02 +0200 Subject: [PATCH] Use changeset in user registration mix task. --- lib/mix/tasks/register_user.ex | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/mix/tasks/register_user.ex b/lib/mix/tasks/register_user.ex index 17535f190..48236439b 100644 --- a/lib/mix/tasks/register_user.ex +++ b/lib/mix/tasks/register_user.ex @@ -6,15 +6,17 @@ defmodule Mix.Tasks.RegisterUser do @shortdoc "Register user" def run([name, nickname, email, bio, password]) do ensure_started(Repo, []) - user = %User{ + + params = %{ name: name, nickname: nickname, email: email, - password_hash: Comeonin.Pbkdf2.hashpwsalt(password), + password: password, + password_confirmation: password, bio: bio } - user = %{ user | ap_id: User.ap_id(user), following: User.ap_followers(user) } + user = User.register_changeset(%User{}, params) Repo.insert!(user) end -- 2.45.2