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