diff --git a/lib/pleroma/web/common_api/utils.ex b/lib/pleroma/web/common_api/utils.ex index d9f80ee0f..e774743a2 100644 --- a/lib/pleroma/web/common_api/utils.ex +++ b/lib/pleroma/web/common_api/utils.ex @@ -189,7 +189,7 @@ defmodule Pleroma.Web.CommonAPI.Utils do def confirm_current_password(user, params) do with %User{local: true} = db_user <- Repo.get(User, user.id), - true <- Pbkdf2.checkpw(params["password"], db_user.password_hash) do + true <- Pbkdf2.checkpw(params["password"], db_user.password_hash) do {:ok, db_user} else _ -> {:error, "Invalid password."} diff --git a/test/web/common_api/common_api_utils_test.exs b/test/web/common_api/common_api_utils_test.exs index d59864c43..23cce471f 100644 --- a/test/web/common_api/common_api_utils_test.exs +++ b/test/web/common_api/common_api_utils_test.exs @@ -18,19 +18,14 @@ defmodule Pleroma.Web.CommonAPI.UtilsTest do end describe "it confirms the password given is the current users password" do - test "with no credentials" do - assert Utils.confirm_current_password(nil, %{"password" => "test"}) == - {:error, "Invalid credentials."} - end - - test "with incorrect password given" do + test "incorrect password given" do {:ok, user} = UserBuilder.insert() assert Utils.confirm_current_password(user, %{"password" => ""}) == {:error, "Invalid password."} end - test "with correct password given" do + test "correct password given" do {:ok, user} = UserBuilder.insert() assert Utils.confirm_current_password(user, %{"password" => "test"}) == {:ok, user} end