Sha256: dd84b836a365ebc591f48b525772349ef682bf321176c23a609d4fe036e88f64
Contents?: true
Size: 1.84 KB
Versions: 8
Compression:
Stored size: 1.84 KB
Contents
module Locomotive module Api class TokensController < Locomotive::Api::BaseController skip_before_filter :require_account, :require_site, :set_locale, :set_current_thread_variables def create begin token = Account.create_api_token(current_site, params[:email], params[:password], params[:api_key]) respond_with({ token: token }, location: root_url) rescue Exception => e respond_with({ message: e.message }, status: 401, location: root_url) end end 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 protected def self.description { overall: %{Manage a session token which will be passed to all the other REST calls}, actions: { create: { description: %{Generate a session token from either an email and a password OR an api key}, params: { email: 'String', password: 'String' }, response: { token: 'String' }, example: { command: %{curl -d 'email=john.doe@acme.org&password=secret' 'http://mysite.com/locomotive/api/tokens.json'}, response: %({ "token": "dtsjkqs1TJrWiSiJt2gg" }) } }, destroy: { description: %{Make a session token invalid}, response: { token: 'String' }, example: { command: %{curl -X DELETE 'http://mysite.com/locomotive/api/tokens/dtsjkqs1TJrWiSiJt2gg.json'}, response: %({ "token": "dtsjkqs1TJrWiSiJt2gg" }) } } } } end end end end
Version data entries
8 entries across 8 versions & 1 rubygems