Send welcome email only after user has been confirmed and approved
Currently right after a successful POST /api/v1/accounts
, this code is always run:
def post_register_action(%User{} = user) do
with {:ok, user} <- autofollow_users(user),
{:ok, user} <- set_cache(user),
{:ok, _} <- send_welcome_email(user),
{:ok, _} <- send_welcome_message(user),
{:ok, _} <- send_welcome_chat_message(user),
{:ok, _} <- try_send_confirmation_email(user) do
{:ok, user}
end
end
However, it doesn't make sense to send_welcome_email(user)
before the user has been confirmed and activated.
Instead, this code should only be run after an account is active, which should be checked after the user confirms their email and after an account is approved.