[#114] Allowed unconfirmed users to authenticate if :account_activation_required...
authorIvan Tashkinov <ivantashkinov@gmail.com>
Thu, 20 Dec 2018 11:48:48 +0000 (14:48 +0300)
committerIvan Tashkinov <ivantashkinov@gmail.com>
Thu, 20 Dec 2018 11:48:48 +0000 (14:48 +0300)
Ensured that no confirmation emails are sent if :account_activation_required is not true. Adjusted tests.

lib/pleroma/user.ex
test/web/twitter_api/twitter_api_controller_test.exs

index ad50cf5582a6eed05ca2ef4b4779fc3fcde0c7f9..f8827abeccafc8a411ba214df8aa6faf752ad135 100644 (file)
@@ -38,7 +38,10 @@ defmodule Pleroma.User do
     timestamps()
   end
 
-  def auth_active?(%User{} = user), do: user.info && !user.info.confirmation_pending
+  def auth_active?(%User{} = user) do
+    (user.info && !user.info.confirmation_pending) ||
+      !Pleroma.Config.get([:instance, :account_activation_required])
+  end
 
   def superuser?(%User{} = user), do: user.info && User.Info.superuser?(user.info)
 
@@ -220,7 +223,8 @@ defmodule Pleroma.User do
   end
 
   def try_send_confirmation_email(%User{} = user) do
-    if user.info.confirmation_pending do
+    if user.info.confirmation_pending &&
+         Pleroma.Config.get([:instance, :account_activation_required]) do
       user
       |> Pleroma.UserEmail.account_confirmation_email()
       |> Pleroma.Mailer.deliver()
index 16422c35ad8508b884bec1d412eb67cac2aacca9..1324bcc713d9b4012394f6f708576a33fb68126e 100644 (file)
@@ -919,6 +919,13 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do
 
   describe "POST /api/account/resend_confirmation_email" do
     setup do
+      setting = Pleroma.Config.get([:instance, :account_activation_required])
+
+      unless setting do
+        Pleroma.Config.put([:instance, :account_activation_required], true)
+        on_exit(fn -> Pleroma.Config.put([:instance, :account_activation_required], setting) end)
+      end
+
       user = insert(:user)
       info_change = User.Info.confirmation_changeset(user.info, :unconfirmed)