Skip to content

Commit c699ee7

Browse files
committed
Tidy up a few helpful method for user
1 parent f04ad33 commit c699ee7

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

app/controllers/application_controller.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,15 +105,15 @@ def redirect_path
105105
end
106106

107107
def authenticate_admin!
108-
redirect_to root_path, notice: "You can't be here" unless logged_in? && current_user.has_role?(:admin)
108+
redirect_to root_path, notice: "You can't be here" unless logged_in? && current_user.is_admin?
109109
end
110110

111111
def authenticate_admin_or_organiser!
112112
redirect_to root_path, notice: "You can't be here" unless manager?
113113
end
114114

115115
def manager?
116-
logged_in? && (current_user.is_admin? || current_user.has_role?(:organiser, :any))
116+
logged_in? && current_user.manager?
117117
end
118118

119119
helper_method :manager?

app/models/member.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ class Member < ApplicationRecord
6161

6262
attr_accessor :attendance, :newsletter
6363

64+
def manager?
65+
is_admin? || has_role?(:organiser, :any)
66+
end
67+
6468
def banned?
6569
bans.active.present? || bans.permanent.present?
6670
end

0 commit comments

Comments
 (0)