aboutsummaryrefslogtreecommitdiff
path: root/app/controllers/users_controller.rb
blob: 9a3cf742d77b6e0cb7b04287f355db8faaf4d36f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# SPDX-FileCopyrightText: 2020 IN COMMON Collective <collective@incommon.cc>
#
# SPDX-License-Identifier: AGPL-3.0-or-later

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