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

27 lines
578 B
Ruby
Raw Normal View History

2016-10-04 14:24:47 +00:00
# frozen_string_literal: true
2017-11-06 16:15:18 +00:00
2016-10-04 14:24:47 +00:00
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