about summary refs log tree commit diff
path: root/app/policies
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2019-03-14 05:28:30 +0100
committerGitHub <noreply@github.com>2019-03-14 05:28:30 +0100
commit51e154f5e87968d6bb115e053689767ab33e80cd (patch)
treed86ba475bfc61ba7a774bf36e24704dc82f68991 /app/policies
parent6e3936aa6f4296ac202b54c0b178b4fa825d7885 (diff)
Admission-based registrations mode (#10250)
Fix #6856
Fix #6951
Diffstat (limited to 'app/policies')
-rw-r--r--app/policies/user_policy.rb10
1 files changed, 9 insertions, 1 deletions
diff --git a/app/policies/user_policy.rb b/app/policies/user_policy.rb
index 57af5c61c..d832bff75 100644
--- a/app/policies/user_policy.rb
+++ b/app/policies/user_policy.rb
@@ -21,6 +21,14 @@ class UserPolicy < ApplicationPolicy
     staff?
   end
 
+  def approve?
+    staff? && !record.approved?
+  end
+
+  def reject?
+    staff? && !record.approved?
+  end
+
   def disable?
     staff? && !record.admin?
   end
@@ -36,7 +44,7 @@ class UserPolicy < ApplicationPolicy
   private
 
   def promoteable?
-    !record.staff? || !record.admin?
+    record.approved? && (!record.staff? || !record.admin?)
   end
 
   def demoteable?