Skip to content

Commit 58b5849

Browse files
committed
refactor: Renames user roles, improves security
commit 1daa943 Author: Peter Kos <[email protected]> Date: Sun Sep 20 02:57:01 2020 -0400 Organizers have same overview page access as direc commit cdf57b6 Author: Peter Kos <[email protected]> Date: Sun Sep 20 02:56:41 2020 -0400 Volunteers are redirected to checkin route commit 3f2a30c Merge: b5ad3b8 d87269d Author: Chris Baudouin, Jr <[email protected]> Date: Sun Sep 20 00:30:03 2020 -0400 Merge branch '2.0' into hm-242 commit b5ad3b8 Author: Jeremy Rudman <[email protected]> Date: Sat Sep 19 21:03:08 2020 -0400 fix(sidebar): fixed UI problems for diffrent roles removed the duplicate checkin button for orginizers and had checkin page defaut to be highlighted for volenteers commit 057e3aa Merge: 971dd0a 69e8d6e Author: Chris Baudouin, Jr <[email protected]> Date: Mon Sep 14 16:43:59 2020 -0400 Merge branch '2.0' into hm-242 commit 971dd0a Author: Chris Baudouin, Jr <[email protected]> Date: Mon Sep 14 16:37:18 2020 -0400 refactor: Increases funciton clarity commit 711aeea Author: Chris Baudouin, Jr <[email protected]> Date: Mon Sep 14 16:35:56 2020 -0400 refactor: Increases funciton clarity commit 19f1926 Author: Chris Baudouin, Jr <[email protected]> Date: Sat Sep 12 00:46:52 2020 -0400 fix: Hound issues v1 commit c3d44f0 Merge: 2ab8865 a767446 Author: Chris Baudouin, Jr <[email protected]> Date: Sat Sep 12 00:32:30 2020 -0400 Merge branch '2.0' into hm-242 commit 2ab8865 Author: Chris Baudouin, Jr <[email protected]> Date: Sat Sep 12 00:29:43 2020 -0400 refactor: Cleans tests, improves coverage commit 59d54ed Merge: 274787f cb16869 Author: Chris Baudouin, Jr <[email protected]> Date: Mon Sep 7 00:11:19 2020 -0400 Merge branch '2.0' into hm-242 commit 274787f Author: Chris Baudouin, Jr <[email protected]> Date: Sun Sep 6 23:59:27 2020 -0400 refactor: Renames event_tracking to Volunteer commit 873e43c Author: Chris Baudouin, Jr <[email protected]> Date: Sun Sep 6 23:48:29 2020 -0400 refactor: Renames admin_limited_access to Organizer commit f592750 Author: Chris Baudouin, Jr <[email protected]> Date: Sun Sep 6 19:38:54 2020 -0400 refactor: Changes admin to director
1 parent 0237965 commit 58b5849

File tree

60 files changed

+847
-244
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+847
-244
lines changed

app/assets/javascripts/manage/lib/setupDataTables.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ var setupDataTables = function () {
3636
],
3737
});
3838

39-
$('.datatable.admins').DataTable({
39+
$('.datatable.staff').DataTable({
4040
order: [2, 'asc'],
4141
columns: [
4242
{ orderable: true, data: 'id', visible: false },

app/controllers/manage/application_controller.rb

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,30 @@
11
class Manage::ApplicationController < ApplicationController
22
before_action :logged_in
3-
before_action :require_admin_or_limited_admin
4-
before_action :limit_write_access_to_admins, only: ["edit", "update", "new", "create", "destroy", "deliver", "merge", "perform_merge", "toggle_bus_captain", "duplicate", "update_acc_status", "send_update_email", "live_preview"]
3+
before_action :require_director_or_organizer_or_volunteer
4+
before_action :limit_write_access_to_directors, only: ["edit", "update", "new", "create", "destroy", "deliver", "merge", "perform_merge", "toggle_bus_captain", "duplicate", "update_acc_status", "send_update_email", "live_preview"]
55
skip_before_action :verify_authenticity_token, if: :json_request?
66

77
def logged_in
88
authenticate_user!
99
end
1010

11-
def require_full_admin
12-
return redirect_to root_path unless current_user.try(:admin?)
11+
def require_director
12+
return redirect_to manage_checkins_path if current_user.volunteer?
13+
return redirect_to manage_root_path if current_user.organizer?
14+
return redirect_to root_path unless current_user.try(:director?)
1315
end
1416

15-
def require_admin_or_limited_admin
16-
return redirect_to root_path unless current_user.try(:admin?) || current_user.try(:admin_limited_access?)
17+
def require_director_or_organizer
18+
return redirect_to manage_checkins_path if current_user.volunteer?
19+
return redirect_to root_path unless current_user.organizing_staff?
1720
end
1821

19-
def require_admin_or_limited_admin_or_event_tracking
20-
redirect_to root_path unless current_user.try(:admin?) || current_user.try(:admin_limited_access?) || current_user.try(:event_tracking?)
22+
def require_director_or_organizer_or_volunteer
23+
redirect_to root_path unless current_user.staff?
2124
end
2225

23-
def limit_write_access_to_admins
24-
redirect_to url_for(controller: controller_name, action: :index) unless current_user.try(:admin?)
26+
def limit_write_access_to_directors
27+
redirect_to url_for(controller: controller_name, action: :index) unless current_user.try(:director?)
2528
end
2629

2730
def json_request?

app/controllers/manage/configs_controller.rb

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
class Manage::ConfigsController < Manage::ApplicationController
2-
before_action :limit_access_admin
2+
before_action :require_director
33
before_action :get_config, only: [:edit, :update, :update_only_css_variables]
44

55
respond_to :html, :json
@@ -69,7 +69,4 @@ def get_config
6969
end
7070
end
7171

72-
def limit_access_admin
73-
redirect_to root_path unless current_user.admin?
74-
end
7572
end

app/controllers/manage/dashboard_controller.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
class Manage::DashboardController < Manage::ApplicationController
2-
skip_before_action :require_admin_or_limited_admin
3-
before_action :require_admin_or_limited_admin
2+
before_action :require_director_or_organizer
43

54
def index
65
end

app/controllers/manage/data_exports_controller.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
class Manage::DataExportsController < Manage::ApplicationController
2-
skip_before_action :require_admin_or_limited_admin
3-
before_action :require_full_admin
2+
before_action :require_director
43

54
before_action :set_data_export, only: [:destroy]
65

app/controllers/manage/messages_controller.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
class Manage::MessagesController < Manage::ApplicationController
2+
before_action :require_director_or_organizer
23
before_action :set_message, only: [:show, :edit, :update, :destroy, :deliver, :preview, :duplicate]
34
before_action :check_message_access, only: [:edit, :update, :destroy]
4-
before_action :limit_template_access_to_admins, only: [:template, :template_preview, :template_update, :template_replace_with_default]
5+
before_action :limit_template_access_to_directors, only: [:template, :template_preview, :template_update, :template_replace_with_default]
56

67
respond_to :html, :json
78

@@ -106,9 +107,9 @@ def template_replace_with_default
106107

107108
private
108109

109-
def limit_template_access_to_admins
110+
def limit_template_access_to_directors
110111
# From Manage::ApplicationController
111-
limit_write_access_to_admins
112+
limit_write_access_to_directors
112113
end
113114

114115
def message_params

app/controllers/manage/stats_controller.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
class Manage::StatsController < Manage::ApplicationController
2+
before_action :require_director_or_organizer
23

34
respond_to :html, :json
45

app/controllers/manage/trackable_events_controller.rb

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
class Manage::TrackableEventsController < Manage::ApplicationController
2-
skip_before_action :require_admin_or_limited_admin
3-
before_action :require_admin_or_limited_admin_or_event_tracking
4-
52
before_action :set_trackable_event, only: [:show, :edit, :update, :destroy]
6-
before_action :scope_limited_admin_access, only: [:edit, :update, :destroy]
3+
before_action :scope_organizer_access, only: [:edit, :update, :destroy]
74

85
respond_to :html, :json
96

@@ -81,13 +78,13 @@ def trackable_event_params
8178
params.require(:trackable_event).permit(:band_id, :trackable_tag_id)
8279
end
8380

84-
# Permit limited-access admins (overrides Manage::ApplicationController#limit_write_access_to_admins)
85-
def limit_write_access_to_admins
81+
# Permit limited-access directors (overrides Manage::ApplicationController#limit_write_access_to_directors)
82+
def limit_write_access_to_directors
8683
end
8784

88-
# If the user isn't a full admin, scope changes only to those they created
89-
def scope_limited_admin_access
90-
return if current_user.admin? || @trackable_event.blank? || @trackable_event.user.blank?
85+
# If the user isn't a director, scope changes only to those they created
86+
def scope_organizer_access
87+
return if current_user.director? || @trackable_event.blank? || @trackable_event.user.blank?
9188
redirect_to manage_trackable_events_path, notice: 'You may not view events you did not create.' if @trackable_event.user != current_user
9289
end
9390
end

app/controllers/manage/trackable_tags_controller.rb

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
class Manage::TrackableTagsController < Manage::ApplicationController
2-
skip_before_action :require_admin_or_limited_admin
3-
before_action :require_admin_or_limited_admin_or_event_tracking
4-
52
before_action :set_trackable_tag, only: [:show, :edit, :update, :destroy]
63

74
respond_to :html, :json

app/controllers/manage/users_controller.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
class Manage::UsersController < Manage::ApplicationController
2-
before_action :require_full_admin
2+
before_action :require_director
33
before_action :find_user, only: [:show, :edit, :update, :destroy]
44

55
respond_to :html, :json
66

77
def index
8-
respond_with(:manage, User.where(role: [:admin, :admin_limited_access, :event_tracking]))
8+
respond_with(:manage, User.where(role: [:director, :organizer, :volunteer]))
99
end
1010

1111
def user_datatable
1212
render json: UserDatatable.new(params, view_context: view_context)
1313
end
1414

15-
def admin_datatable
16-
render json: AdminDatatable.new(params, view_context: view_context)
15+
def staff_datatable
16+
render json: StaffDatatable.new(params, view_context: view_context)
1717
end
1818

1919
def show

0 commit comments

Comments
 (0)