From 9c3319050f22e05602d494c932e4ece58a751071 Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Sat, 13 Jun 2026 18:24:06 -0500 Subject: [PATCH] credo fixes --- .credo.exs | 4 ++-- lib/towerops_web/live/account_live/totp_enrollment.ex | 6 ++++++ lib/towerops_web/live/admin/audit_live/index.ex | 2 +- lib/towerops_web/live/user_registration_live.ex | 2 +- lib/towerops_web/live/user_reset_password_live.ex | 2 +- 5 files changed, 11 insertions(+), 5 deletions(-) diff --git a/.credo.exs b/.credo.exs index 1e188300..dab1765b 100644 --- a/.credo.exs +++ b/.credo.exs @@ -181,14 +181,14 @@ |> String.replace_leading("lib/", "test/") |> String.replace_trailing(".ex", "_test.exs") end - ]} + ]}, # {Jump.CredoChecks.ForbiddenFunction, # [ # functions: [ # {:erlang, :binary_to_term, "Use Plug.Crypto.non_executable_binary_to_term/2 instead."} # ] # ]}, - # {Jump.CredoChecks.LiveViewFormCanBeRehydrated}, + {Jump.CredoChecks.LiveViewFormCanBeRehydrated} # {Jump.CredoChecks.UndeclaredExternalResource}, # {Jump.CredoChecks.PreferChangeOverUpDownMigrations, [start_after: "20250101000000"]}, # {Jump.CredoChecks.PreferTextColumns, [start_after: "20250101000000"]}, diff --git a/lib/towerops_web/live/account_live/totp_enrollment.ex b/lib/towerops_web/live/account_live/totp_enrollment.ex index 382b3a42..23e4de8d 100644 --- a/lib/towerops_web/live/account_live/totp_enrollment.ex +++ b/lib/towerops_web/live/account_live/totp_enrollment.ex @@ -109,6 +109,10 @@ defmodule ToweropsWeb.AccountLive.TotpEnrollment do |> redirect(to: redirect_path)} end + def handle_event("validate_code", _params, socket) do + {:noreply, socket} + end + defp handle_valid_code(socket, user, secret) do # Create first TOTP device (new multi-device system) case Accounts.create_totp_device(user.id, "Primary Device", secret) do @@ -317,6 +321,8 @@ defmodule ToweropsWeb.AccountLive.TotpEnrollment do <.form for={%{}} as={:form} + id="totp-verify-form" + phx-change="validate_code" phx-submit="verify_code" class="ml-11 flex flex-col items-center" > diff --git a/lib/towerops_web/live/admin/audit_live/index.ex b/lib/towerops_web/live/admin/audit_live/index.ex index 73d8b2ba..4120654f 100644 --- a/lib/towerops_web/live/admin/audit_live/index.ex +++ b/lib/towerops_web/live/admin/audit_live/index.ex @@ -92,7 +92,7 @@ defmodule ToweropsWeb.Admin.AuditLive.Index do
-
+
- <.form for={@form} phx-change="validate" phx-submit="save"> + <.form for={@form} id="registration-form" phx-change="validate" phx-submit="save"> <%= if @invitation_token do %> <% end %> diff --git a/lib/towerops_web/live/user_reset_password_live.ex b/lib/towerops_web/live/user_reset_password_live.ex index c43fa20b..4b11e17d 100644 --- a/lib/towerops_web/live/user_reset_password_live.ex +++ b/lib/towerops_web/live/user_reset_password_live.ex @@ -79,7 +79,7 @@ defmodule ToweropsWeb.UserResetPasswordLive do
- <.form for={@form} phx-change="validate" phx-submit="save"> + <.form for={@form} id="reset-password-form" phx-change="validate" phx-submit="save"> <.input field={@form[:password]} type="password"