Class: Locomotive::Api::TokensController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/locomotive/api/tokens_controller.rb

Instance Method Summary collapse

Methods included from Locomotive::ActionController::LocaleHelpers

#back_to_default_site_locale, #current_content_locale, #localized?, #set_back_office_locale, #set_current_content_locale, #setup_i18n_fallbacks

Instance Method Details

#createObject



7
8
9
10
11
12
13
14
# File 'app/controllers/locomotive/api/tokens_controller.rb', line 7

def create
  begin
    token = Account.create_api_token(current_site, params[:email], params[:password])
    respond_with({ token: token }, location: root_url)
  rescue Exception => e
    respond_with({ message: e.message }, status: 401, location: root_url)
  end
end

#destroyObject



16
17
18
19
20
21
22
23
# File 'app/controllers/locomotive/api/tokens_controller.rb', line 16

def destroy
  begin
    token = Account.invalidate_api_token(params[:id])
    respond_with({ token: token }, location: root_url)
  rescue Exception => e
    respond_with({ message: e.message }, status: 404, location: root_url)
  end
end