about summary refs log tree commit diff
path: root/app/models
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2019-03-23 02:23:48 +0100
committerGitHub <noreply@github.com>2019-03-23 02:23:48 +0100
commit00d988955f63551e86dd33ca1a26f73f7d0c7b45 (patch)
tree7d426c9731cfc9cec59217e26193885487e4f780 /app/models
parent013a9e0bed871b92103162cb4a1d60934141c391 (diff)
If registrations have been re-opened when user confirms account, approve (#10349)
Diffstat (limited to 'app/models')
-rw-r--r--app/models/user.rb12
1 files changed, 9 insertions, 3 deletions
diff --git a/app/models/user.rb b/app/models/user.rb
index 9d0d49676..d703f9588 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -124,7 +124,8 @@ class User < ApplicationRecord
   end
 
   def confirm
-    new_user = !confirmed?
+    new_user      = !confirmed?
+    self.approved = true if open_registrations?
 
     super
 
@@ -136,7 +137,8 @@ class User < ApplicationRecord
   end
 
   def confirm!
-    new_user = !confirmed?
+    new_user      = !confirmed?
+    self.approved = true if open_registrations?
 
     skip_confirmation!
     save!
@@ -264,7 +266,11 @@ class User < ApplicationRecord
   private
 
   def set_approved
-    self.approved = Setting.registrations_mode == 'open' || invited?
+    self.approved = open_registrations? || invited?
+  end
+
+  def open_registrations?
+    Setting.registrations_mode == 'open'
   end
 
   def sanitize_languages