Skip to content

Commit 4bcac05

Browse files
committed
Added initializer for good_job
1 parent 5a1c34d commit 4bcac05

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

config/initializers/good_job.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
Rails.application.config.to_prepare do
2+
GoodJob::ApplicationController.class_eval do
3+
def current_user
4+
@current_user ||= User.find_by(canvas_uid: session[:user_id])
5+
end
6+
7+
before_action :require_admin
8+
9+
def require_admin
10+
if current_user.nil?
11+
redirect_to '/', alert: 'You must be logged in.'
12+
elsif !current_user.admin?
13+
redirect_to '/', alert: 'You are not authorized to view this page.'
14+
end
15+
end
16+
end
17+
end

0 commit comments

Comments
 (0)