Sha256: aae6324e5278becfe3605ebd22428387d2d91c096f1369854caf3bada152eb84

Contents?: true

Size: 1.05 KB

Versions: 1

Compression:

Stored size: 1.05 KB

Contents

# frozen_string_literal: true

# @resource Users
#
# Users can belong to many tenants and many groups.
PUNK.route("users") do
  require_session!
  require_tenant!

  # Retrieve the list of users visible to the authenticated user for a specific tenant or group.
  # @path [GET] /users
  # @parameter tenant_id(required) [string] The ID of a tenant visible to the authenticated user.
  # @parameter group_id [string] The ID of a group that belongs to the tenant.
  # @response [Array<User>] 200 List of users
  # @method get
  # @example 200
  #   [{
  #     "id": "deadbeef-1234-5678-abcd-000000000000",
  #     "name": "John Smith",
  #     "icon": "https://some.image/url"
  #   }]
  # @example 401
  #   {
  #     "message": "You must specify a tenant.",
  #     "errors": ["Cannot find tenant"]
  #   }
  #
  # route: GET /users
  get do
    if args[:group_id]
      perform PUNK::ListGroupUsersAction, group: current_user.groups_dataset[tenant: current_tenant, id: args[:group_id]]
    else
      perform PUNK::ListTenantUsersAction, tenant: current_tenant
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
punk-0.4.1 lib/punk/routes/users.rb