Commit 4f6a51d3 by Xuan Trung Le

fix bugs: admin can apply or favorite job

parent 0520750e
class ApplicationController < ActionController::Base class ApplicationController < ActionController::Base
protect_from_forgery with: :exception protect_from_forgery with: :exception
helper_method :clear_session_candidate helper_method :clear_session_candidate, :admin_can_not_do_this
def clear_session_candidate def clear_session_candidate
session[:candidate] = {} session[:candidate] = {}
...@@ -14,4 +14,11 @@ class ApplicationController < ActionController::Base ...@@ -14,4 +14,11 @@ class ApplicationController < ActionController::Base
super super
end end
end end
def admin_can_not_do_this
if current_admin
flash[:notice] = "Admin can't do this"
redirect_back(fallback_location: root_path)
end
end
end end
class AppliesController < ApplicationController class AppliesController < ApplicationController
before_action :admin_can_not_do_this
before_action :authenticate_user! before_action :authenticate_user!
def apply def apply
session[:job_id] = params[:job_id] if params[:job_id] session[:job_id] = params[:job_id] if params[:job_id]
......
class FavoritesController < ApplicationController class FavoritesController < ApplicationController
before_action :admin_can_not_do_this
before_action :authenticate_user! before_action :authenticate_user!
def index def index
@jobs = current_user.liked_jobs.includes(:company) @jobs = current_user.liked_jobs.includes(:company)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment