diff --git a/lib/recycledcloud/accounts.ex b/lib/recycledcloud/accounts.ex index 089a036..9a95a10 100644 --- a/lib/recycledcloud/accounts.ex +++ b/lib/recycledcloud/accounts.ex @@ -377,7 +377,7 @@ defmodule RecycledCloud.Accounts do changeset = user |> User.password_changeset(attrs) - set_user_password(user, changeset, attrs["password"]) + set_user_password(user, changeset, changeset.changes.password) end ## Keys diff --git a/test/recycledcloud_web/controllers/user_confirmation_controller_test.exs b/test/recycledcloud_web/controllers/user_confirmation_controller_test.exs index daed384..3928b48 100644 --- a/test/recycledcloud_web/controllers/user_confirmation_controller_test.exs +++ b/test/recycledcloud_web/controllers/user_confirmation_controller_test.exs @@ -22,7 +22,7 @@ defmodule RecycledCloudWeb.UserConfirmationControllerTest do test "sends a new confirmation token", %{conn: conn, user: user} do conn = post(conn, Routes.user_confirmation_path(conn, :create), %{ - "user" => %{"email" => user.email} + "user" => %{"username" => user.username} }) assert redirected_to(conn) == "/" @@ -35,7 +35,7 @@ defmodule RecycledCloudWeb.UserConfirmationControllerTest do conn = post(conn, Routes.user_confirmation_path(conn, :create), %{ - "user" => %{"email" => user.email} + "user" => %{"username" => user.username} }) assert redirected_to(conn) == "/" @@ -43,10 +43,10 @@ defmodule RecycledCloudWeb.UserConfirmationControllerTest do refute Repo.get_by(Accounts.UserToken, user_id: user.id) end - test "does not send confirmation token if email is invalid", %{conn: conn} do + test "does not send confirmation token if usernameis invalid", %{conn: conn} do conn = post(conn, Routes.user_confirmation_path(conn, :create), %{ - "user" => %{"email" => "unknown@example.com"} + "user" => %{"username" => "unknown"} }) assert redirected_to(conn) == "/" diff --git a/test/recycledcloud_web/controllers/user_registration_controller_test.exs b/test/recycledcloud_web/controllers/user_registration_controller_test.exs index 5dc9b72..20330fb 100644 --- a/test/recycledcloud_web/controllers/user_registration_controller_test.exs +++ b/test/recycledcloud_web/controllers/user_registration_controller_test.exs @@ -21,11 +21,12 @@ defmodule RecycledCloudWeb.UserRegistrationControllerTest do describe "POST /users/register" do @tag :capture_log test "creates account and logs the user in", %{conn: conn} do + username = unique_user_name() email = unique_user_email() conn = post(conn, Routes.user_registration_path(conn, :create), %{ - "user" => %{"email" => email, "password" => valid_user_password()} + "user" => %{"username" => username, "email" => email, "password" => valid_user_password()} }) assert get_session(conn, :user_token) @@ -34,7 +35,6 @@ defmodule RecycledCloudWeb.UserRegistrationControllerTest do # Now do a logged in request and assert on the menu conn = get(conn, "/") response = html_response(conn, 200) - assert response =~ email assert response =~ "Settings" assert response =~ "Log out" end @@ -42,13 +42,13 @@ defmodule RecycledCloudWeb.UserRegistrationControllerTest do test "render errors for invalid data", %{conn: conn} do conn = post(conn, Routes.user_registration_path(conn, :create), %{ - "user" => %{"email" => "with spaces", "password" => "too short"} + "user" => %{"username" => "with spaces", "email" => "with spaces", "password" => "too"} }) response = html_response(conn, 200) assert response =~ "