Skip to content

Commit

Permalink
Add registration emails on OAuth signup
Browse files Browse the repository at this point in the history
This is a copy and only manually tested… ugh
  • Loading branch information
backspace committed Jul 21, 2024
1 parent 64deb18 commit afad3a9
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
3 changes: 3 additions & 0 deletions registrations/config/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ config :registrations, :pow,
messages_backend: RegistrationsWeb.Pow.Messages,
users_context: RegistrationsWeb.Pow.Users

config :registrations, :pow_assent,
user_identities_context: RegistrationsWeb.PowAssent.UserIdentities

# Configure phoenix generators
config :phoenix, :generators,
migration: true,
Expand Down
32 changes: 32 additions & 0 deletions registrations/lib/registrations_web/pow_assent/user_identities.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
defmodule RegistrationsWeb.PowAssent.UserIdentities do
use PowAssent.Ecto.UserIdentities.Context,
repo: Registrations.Repo,
user: RegistrationsWeb.User

import Ecto.Query, only: [from: 2]

def create_user(user_identity_params, user_params, user_id_params) do
case pow_assent_create_user(user_identity_params, user_params, user_id_params) do
{:ok, user} ->
messages =
Registrations.Repo.all(
from(m in RegistrationsWeb.Message,
where: m.ready == true,
select: m,
order_by: :postmarked_at
)
)

unless Enum.empty?(messages) do
Registrations.Mailer.send_backlog(messages, user)
end

Registrations.Mailer.send_welcome_email(user.email)
Registrations.Mailer.send_registration(user)
{:ok, user}

{:error, changeset} ->
{:error, changeset}
end
end
end

0 comments on commit afad3a9

Please sign in to comment.