aboutsummaryrefslogtreecommitdiff
path: root/app/helpers
diff options
context:
space:
mode:
authorhellekin <hellekin@cepheide.org>2020-10-09 10:31:10 +0200
committerhellekin <hellekin@cepheide.org>2020-10-09 10:31:10 +0200
commitef9ff49462c3fdf10d0cdcbb6304715769485835 (patch)
treee4981e12866c1c30d07c75c83a65feb324459ec4 /app/helpers
parentd242fb5bbc423876f4c192b5f133619a2d4f0113 (diff)
downloadincommon-map-ef9ff49462c3fdf10d0cdcbb6304715769485835.tar.gz
Add permissions
- `current_agent` is now a full instance of Agent - provide helpers to verify current user roles
Diffstat (limited to 'app/helpers')
-rw-r--r--app/helpers/application_helper.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index de6be79..0b22f4b 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -1,2 +1,10 @@
module ApplicationHelper
+ def current_agency
+ current_user.agencies.where(agent: current_agent).first
+ end
+ %w(observer editor maintainer leader).each do |role|
+ define_method :"current_user_#{role}?" do
+ current_agency.send(:"#{role}?")
+ end
+ end
end