fix tokens
This commit is contained in:
parent
521aa6b5d0
commit
bf4fbbeb06
2 changed files with 7 additions and 3 deletions
|
@ -5,7 +5,7 @@ class API::RestfulController < ActionController::Base
|
||||||
snorlax_used_rest!
|
snorlax_used_rest!
|
||||||
|
|
||||||
rescue_from(Pundit::NotAuthorizedError) { |e| respond_with_standard_error e, 403 }
|
rescue_from(Pundit::NotAuthorizedError) { |e| respond_with_standard_error e, 403 }
|
||||||
load_and_authorize_resource except: [:index, :create]
|
load_and_authorize_resource only: [:show, :update, :destroy]
|
||||||
|
|
||||||
def create
|
def create
|
||||||
authorize resource_class
|
authorize resource_class
|
||||||
|
|
|
@ -1,13 +1,17 @@
|
||||||
class Api::TokensController < API::RestfulController
|
class Api::TokensController < API::RestfulController
|
||||||
|
|
||||||
skip_authorization
|
|
||||||
|
|
||||||
def my_tokens
|
def my_tokens
|
||||||
raise Pundit::NotAuthorizedError.new unless current_user
|
raise Pundit::NotAuthorizedError.new unless current_user
|
||||||
instantiate_collection page_collection: false, timeframe_collection: false
|
instantiate_collection page_collection: false, timeframe_collection: false
|
||||||
respond_with_collection
|
respond_with_collection
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def resource_serializer
|
||||||
|
"#{resource_name}_serializer".camelize.constantize
|
||||||
|
end
|
||||||
|
|
||||||
def visible_records
|
def visible_records
|
||||||
current_user.tokens
|
current_user.tokens
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue