2016-09-24 03:00:46 +00:00
|
|
|
# frozen_string_literal: true
|
2017-11-06 16:15:18 +00:00
|
|
|
|
2016-09-21 17:22:40 +00:00
|
|
|
module Api
|
|
|
|
module V2
|
|
|
|
class TokensController < RestfulController
|
2017-02-12 00:29:03 +00:00
|
|
|
protect_from_forgery
|
|
|
|
|
2016-10-04 05:51:07 +00:00
|
|
|
def searchable_columns
|
|
|
|
[:description]
|
|
|
|
end
|
|
|
|
|
2016-10-04 08:02:58 +00:00
|
|
|
def create
|
|
|
|
if params[:token].blank?
|
|
|
|
self.resource = resource_class.new
|
|
|
|
else
|
|
|
|
instantiate_resource
|
|
|
|
end
|
|
|
|
|
|
|
|
resource.user = current_user if current_user.present?
|
|
|
|
authorize resource
|
|
|
|
create_action
|
|
|
|
respond_with_resource
|
|
|
|
end
|
2017-02-12 00:29:03 +00:00
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def current_user
|
|
|
|
token_user || doorkeeper_user || method(:current_user).super_method.super_method.call
|
|
|
|
end
|
2016-09-21 17:22:40 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|