Set up SES mail delivery and harden the mailing list (#120)

* setup basic SES email sending

* basic honeypot form form submission
This commit is contained in:
2026-11-09 16:38:55 +01:00
committed by GitHub
parent 5b3241ae1f
commit cae4e35a70
23 changed files with 731 additions and 64 deletions
+15
View File
@@ -9,6 +9,8 @@ defmodule Chesstrainer.AccountsTest do
alias Chesstrainer.Attempts
alias Chesstrainer.Attempts.Attempt
alias Chesstrainer.Accounts.Scope
alias Chesstrainer.MailingList
alias Chesstrainer.MailingList.Subscriber
describe "get_user_by_email/1" do
test "does not return the user if the email does not exist" do
@@ -340,6 +342,19 @@ defmodule Chesstrainer.AccountsTest do
refute Repo.get_by(UserToken, user_id: user.id)
end
test "updates the linked mailing-list address", %{
user: user,
token: token,
email: email
} do
{:ok, _subscriber} = MailingList.subscribe_user(user)
MailingList.confirm_user_subscription(user)
assert {:ok, %{email: ^email}} = Accounts.update_user_email(user, token)
assert %Subscriber{email: ^email} = Repo.get_by(Subscriber, user_id: user.id)
end
test "does not update email with invalid token", %{user: user} do
assert Accounts.update_user_email(user, "oops") ==
{:error, :transaction_aborted}