Commit 4d284329 by nnnghia98

check if user is admin

parent ae2ea703
class Users::AdminsController < ApplicationController
before_action :authenticate_user!, only: :index
before_action :validate_user, only: :index
def index
redirect_to root_path unless current_user.role?
......@@ -18,6 +17,8 @@ class Users::AdminsController < ApplicationController
@applied_jobs = []
if email != ""
users = User.find_by(email: email)
redirect_to users_admin_path if users.nil?
@applied_jobs = users.jobs
elsif email = "" || nil
all_applied_jobs = UserJob.where.not(applied_at: nil).to_a
......@@ -27,10 +28,4 @@ class Users::AdminsController < ApplicationController
end
end
end
def validate_user
if params[:search_user] != ""
redirect_to users_admin_path unless User.find_by(email: params[:search_user])
end
end
end
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