Merge branch 'from/upstream-develop/tusooa/register-approval' into 'develop'
Fix failure when registering a user with no email when approval required Closes #3021 See merge request pleroma/pleroma!3807
This commit is contained in:
commit
c0cfc454ba
|
@ -905,7 +905,7 @@ def post_register_action(%User{is_approved: true, is_confirmed: true} = user) do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
defp send_user_approval_email(user) do
|
defp send_user_approval_email(%User{email: email} = user) when is_binary(email) do
|
||||||
user
|
user
|
||||||
|> Pleroma.Emails.UserEmail.approval_pending_email()
|
|> Pleroma.Emails.UserEmail.approval_pending_email()
|
||||||
|> Pleroma.Emails.Mailer.deliver_async()
|
|> Pleroma.Emails.Mailer.deliver_async()
|
||||||
|
@ -913,6 +913,10 @@ defp send_user_approval_email(user) do
|
||||||
{:ok, :enqueued}
|
{:ok, :enqueued}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
defp send_user_approval_email(_user) do
|
||||||
|
{:ok, :skipped}
|
||||||
|
end
|
||||||
|
|
||||||
defp send_admin_approval_emails(user) do
|
defp send_admin_approval_emails(user) do
|
||||||
all_superusers()
|
all_superusers()
|
||||||
|> Enum.filter(fn user -> not is_nil(user.email) end)
|
|> Enum.filter(fn user -> not is_nil(user.email) end)
|
||||||
|
|
|
@ -591,6 +591,21 @@ test "it fails gracefully with invalid email config" do
|
||||||
refute_email_sent()
|
refute_email_sent()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "it works when the registering user does not provide an email" do
|
||||||
|
clear_config([Pleroma.Emails.Mailer, :enabled], false)
|
||||||
|
clear_config([:instance, :account_activation_required], false)
|
||||||
|
clear_config([:instance, :account_approval_required], true)
|
||||||
|
|
||||||
|
cng = User.register_changeset(%User{}, @full_user_data |> Map.put(:email, ""))
|
||||||
|
|
||||||
|
# The user is still created
|
||||||
|
assert {:ok, %User{nickname: "nick"}} = User.register(cng)
|
||||||
|
|
||||||
|
# No emails are sent
|
||||||
|
ObanHelpers.perform_all()
|
||||||
|
refute_email_sent()
|
||||||
|
end
|
||||||
|
|
||||||
test "it requires an email, name, nickname and password, bio is optional when account_activation_required is enabled" do
|
test "it requires an email, name, nickname and password, bio is optional when account_activation_required is enabled" do
|
||||||
clear_config([:instance, :account_activation_required], true)
|
clear_config([:instance, :account_activation_required], true)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue