Prefix fire-and-forget calls (PubSub.broadcast, Oban enqueue, Logger, update_*, etc.) with `_ =` so dialyzer knows the return value is intentionally discarded. Wrap a few if/case expressions whose branches produce mixed types the same way. No behavior changes — only explicit acknowledgement of discarded returns. Warnings: 242 → 88.
43 lines
1.1 KiB
Elixir
43 lines
1.1 KiB
Elixir
defmodule ToweropsWeb.UserConfirmationController do
|
|
use ToweropsWeb, :controller
|
|
|
|
alias Towerops.Accounts
|
|
|
|
def new(conn, _params) do
|
|
render(conn, :new)
|
|
end
|
|
|
|
def create(conn, %{"user" => %{"email" => email}}) do
|
|
_ =
|
|
if user = Accounts.get_user_by_email(email) do
|
|
if is_nil(user.confirmed_at) do
|
|
Accounts.deliver_user_confirmation_instructions(
|
|
user,
|
|
&url(~p"/users/confirm/#{&1}")
|
|
)
|
|
end
|
|
end
|
|
|
|
# Always show success to prevent email enumeration
|
|
conn
|
|
|> put_flash(
|
|
:info,
|
|
"If your email is in our system and has not yet been confirmed, you will receive an email with instructions shortly."
|
|
)
|
|
|> redirect(to: ~p"/users/log-in")
|
|
end
|
|
|
|
def confirm(conn, %{"token" => token}) do
|
|
case Accounts.confirm_user(token) do
|
|
{:ok, _user} ->
|
|
conn
|
|
|> put_flash(:info, t("Email confirmed successfully. You may now log in."))
|
|
|> redirect(to: ~p"/users/log-in")
|
|
|
|
:error ->
|
|
conn
|
|
|> put_flash(:error, t("Email confirmation link is invalid or has expired."))
|
|
|> redirect(to: ~p"/users/log-in")
|
|
end
|
|
end
|
|
end
|