diff options
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/application_controller.rb | 5 | ||||
-rw-r--r-- | app/controllers/resources_controller.rb | 13 | ||||
-rw-r--r-- | app/controllers/users_controller.rb | 20 |
3 files changed, 38 insertions, 0 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index c34b9f9..4e71ff8 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -7,6 +7,11 @@ class ApplicationController < ActionController::Base protected + def current_agent + @current_agent = session[:current_agent] || current_user.presence&.agents&.first&.name || 'IN COMMON' + end + helper_method :current_agent + def current_user @current_user ||= User.find_by(external_id: session[:current_user]) if session[:current_user].present? end diff --git a/app/controllers/resources_controller.rb b/app/controllers/resources_controller.rb new file mode 100644 index 0000000..1253b5d --- /dev/null +++ b/app/controllers/resources_controller.rb @@ -0,0 +1,13 @@ +class ResourcesController < ApplicationController + def index + end + + def new + end + + def edit + end + + def delete + end +end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb new file mode 100644 index 0000000..2cfa2ab --- /dev/null +++ b/app/controllers/users_controller.rb @@ -0,0 +1,20 @@ +class UsersController < ApplicationController + # GET /my/users + # If you're a leader, you will see a list of Agent members + def index + begin + return 403 unless current_user.agencies.find_by(name: current_agent).leader? + rescue Exception => e + Rails.logger.info("Exception %s: %s" % [e.class, e.message]) + flash[:notice] = "Talk to your leader!" + redirect_to root_url and return + end + + @users = Agent.where(name: current_agent).members + end + + # GET /my/account + def show + @user = current_user + end +end |