Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configures ActiveJob with solid_queue gem #1415

Open
wants to merge 20 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
adds job_mod_controller
  • Loading branch information
rahul1990gupta committed Jan 6, 2025
commit ed9dd05f7a2398bbd9f1bd710b3e321b349a8231
48 changes: 48 additions & 0 deletions app/controllers/jobs_mod_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
class JobsModController < ActionController::Base
protect_from_forgery
before_action :authenticate_user
before_action :require_logged_in_moderator


def authenticate_user
# eagerly evaluate, in case this triggers an IpSpoofAttackError
request.remote_ip

if Rails.application.read_only?
return true
end

if session[:u] &&
(user = User.find_by(session_token: session[:u].to_s)) &&
user.is_active?
@user = user
end

true
end

def require_logged_in_moderator
require_logged_in_user

if @user
if @user.is_moderator?
true
else
flash[:error] = "You are not authorized to access that resource."
redirect_to "/"
end
end
end

def require_logged_in_user
if @user
true
else
if request.get?
session[:redirect_to] = request.original_fullpath
end

redirect_to "/login"
end
end
end
2 changes: 1 addition & 1 deletion config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class Application < Rails::Application
# rails stop putting js on everything
config.action_view.form_with_generates_remote_forms = false

config.mission_control.jobs.base_controller_class = "AdminController"
config.mission_control.jobs.base_controller_class = "JobsModController"
config.mission_control.jobs.http_basic_auth_enabled = false
end
end
Expand Down