2016-10-04 14:24:47 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
module Api
|
|
|
|
module V2
|
|
|
|
class UsersController < RestfulController
|
|
|
|
def current
|
2017-03-09 19:24:52 +00:00
|
|
|
raise Pundit::NotAuthorizedError if current_user.nil?
|
2016-10-04 14:24:47 +00:00
|
|
|
@user = current_user
|
|
|
|
authorize @user
|
2016-10-04 14:51:21 +00:00
|
|
|
show # delegate to the normal show function
|
2016-10-04 14:24:47 +00:00
|
|
|
end
|
2016-10-04 14:51:21 +00:00
|
|
|
|
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
|
2016-10-29 14:58:31 +00:00
|
|
|
super.merge(show_full_user: action_name == 'current')
|
2016-10-04 14:24:47 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|