diff options
author | David Yip <yipdw@member.fsf.org> | 2017-11-27 11:29:04 -0600 |
---|---|---|
committer | David Yip <yipdw@member.fsf.org> | 2017-11-27 11:29:04 -0600 |
commit | e77c3996a513a45e5cad368b0053459f303c60cb (patch) | |
tree | 923411336e4207bb95c17c90c79f19dabb4d62e2 /app/policies | |
parent | 5de42665d77431def632ca8fb8665082027c60a5 (diff) | |
parent | 1c5b0e333464d8da3de73e4886502c816cb8173e (diff) |
Merge remote-tracking branch 'origin/master' into gs-master
Diffstat (limited to 'app/policies')
-rw-r--r-- | app/policies/invite_policy.rb | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/app/policies/invite_policy.rb b/app/policies/invite_policy.rb new file mode 100644 index 000000000..e5c68af19 --- /dev/null +++ b/app/policies/invite_policy.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +class InvitePolicy < ApplicationPolicy + def index? + staff? + end + + def create? + min_required_role? + end + + def destroy? + owner? || staff? + end + + private + + def owner? + record.user_id == current_user&.id + end + + def min_required_role? + current_user&.role?(Setting.min_invite_role) + end +end |