about summary refs log tree commit diff
path: root/app/models/user.rb
diff options
context:
space:
mode:
authorThibaut Girka <thib@sitedethib.com>2019-03-23 22:10:51 +0100
committerThibaut Girka <thib@sitedethib.com>2019-03-26 16:01:59 +0100
commitfcce135d271276aa38576ed36a113ec3f6161e0a (patch)
treef8faef20945cd7f114d8b718c46901fb10fd3c0f /app/models/user.rb
parent9f56511860493b770c2e535be0f8ce4777c8d373 (diff)
parent9ec98893f4974bb022a722c3163a7e578b1d5ce9 (diff)
Merge branch 'master' into glitch-soc/merge-upstream
Conflicts:
- app/controllers/admin/settings_controller.rb
- app/models/form/admin_settings.rb

Conflicts caused by upstream refactoring, while we have
flavours and skins, with the flavour_and_skin pseudo-setting.
Diffstat (limited to 'app/models/user.rb')
-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 47657a670..66c1543ff 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