Web.AdminAPI.AdminAPIController: Fixes bugs found with ExUnit
authorHaelwenn (lanodan) Monnier <contact@hacktivis.me>
Sat, 17 Nov 2018 21:10:23 +0000 (22:10 +0100)
committerHaelwenn (lanodan) Monnier <contact@hacktivis.me>
Sat, 17 Nov 2018 21:12:14 +0000 (22:12 +0100)
lib/pleroma/web/admin_api/admin_api_controller.ex

index 39e85036ece8fb7c7bcfb5af83848b580759cd17..bcdb4ba37abdaa0934130f853d746a362ecdc110 100644 (file)
@@ -10,7 +10,7 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIController do
   def user_delete(conn, %{"nickname" => nickname}) do
     user = User.get_by_nickname(nickname)
 
-    if user[:local] == true do
+    if user.local == true do
       User.delete(user)
     else
       User.delete(user)
@@ -20,21 +20,21 @@ defmodule Pleroma.Web.AdminAPI.AdminAPIController do
     |> json(nickname)
   end
 
-  def user_create(conn, %{
-        user: %{"nickname" => nickname, "email" => email, "password" => password} = user
-      }) do
-    new_user = %User{
+  def user_create(
+        conn,
+        %{"nickname" => nickname, "email" => email, "password" => password}
+      ) do
+    new_user = %{
       nickname: nickname,
-      name: user.name || nickname,
+      name: nickname,
       email: email,
       password: password,
       password_confirmation: password,
-      bio: user.bio || "."
+      bio: "."
     }
 
     User.register_changeset(%User{}, new_user)
-
-    Repo.insert!(new_user)
+    |> Repo.insert!()
 
     conn
     |> json(new_user.nickname)