metamaps--metamaps/app/controllers/api/v2/users_controller.rb

26 lines
577 B
Ruby
Raw Permalink Normal View History

2016-10-04 14:24:47 +00:00
# frozen_string_literal: true
module Api
module V2
class UsersController < RestfulController
def current
raise Pundit::NotAuthorizedError if current_user.nil?
2016-10-04 14:24:47 +00:00
@user = current_user
authorize @user
show # delegate to the normal show function
2016-10-04 14:24:47 +00:00
end
2016-10-04 14:24:47 +00:00
private
def searchable_columns
[:name]
end
# only ask serializer to return is_admin field if we're on the
# current_user action
def default_scope
super.merge(show_full_user: action_name == 'current')
2016-10-04 14:24:47 +00:00
end
end
end
end