Class: Apress::Api::V1::TokensController

Inherits:
ApiController::Base show all
Defined in:
app/controllers/apress/api/v1/tokens_controller.rb

Constant Summary

Constants included from ApiController::Pagination

ApiController::Pagination::DEFAULT_PER_PAGE, ApiController::Pagination::MAX_PER_PAGE

Instance Method Summary collapse

Methods included from ApiController::Compatibility

#allow_forgery_protection=, #assets_dir=, #helper, #helpers_path=, #include_all_helpers=, #javascripts_dir=, #page_cache_directory=, #relative_url_root=, #stylesheets_dir=

Methods included from ApiController::Pagination

#pagination_headers, #prepare_pagination

Instance Method Details

#createObject



12
13
14
15
16
17
18
19
# File 'app/controllers/apress/api/v1/tokens_controller.rb', line 12

def create
  @client = Apress::Api::Client.find_by_access_id!(params.require(:client_id))

  return bad_request if @client.refresh_token != params.require(:refresh_token)
  return forbidden if @client.refresh_token_expired?

  @client.regenerate_tokens!
end