about summary refs log tree commit diff
path: root/app/models/concerns
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2019-06-20 02:52:34 +0200
committerGitHub <noreply@github.com>2019-06-20 02:52:34 +0200
commit7696f77245c2302787d239da50248385b3292a5e (patch)
tree81db43f660c382679cc7a834d0be06c0218592a8 /app/models/concerns
parent33144e132d28f5b820ae12e4b8e4fb34ca47b1d6 (diff)
Add moderation API (#9387)
Fix #8580
Fix #7143
Diffstat (limited to 'app/models/concerns')
-rw-r--r--app/models/concerns/user_roles.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/app/models/concerns/user_roles.rb b/app/models/concerns/user_roles.rb
index 58dffdc46..a42b4a172 100644
--- a/app/models/concerns/user_roles.rb
+++ b/app/models/concerns/user_roles.rb
@@ -13,6 +13,20 @@ module UserRoles
     admin? || moderator?
   end
 
+  def role=(value)
+    case value
+    when 'admin'
+      self.admin     = true
+      self.moderator = false
+    when 'moderator'
+      self.admin     = false
+      self.moderator = true
+    else
+      self.admin     = false
+      self.moderator = false
+    end
+  end
+
   def role
     if admin?
       'admin'