2012-01-23 08:05:50 +00:00
|
|
|
module Locomotive
|
|
|
|
module Api
|
2012-02-20 16:21:32 +00:00
|
|
|
class TokensController < Locomotive::Api::BaseController
|
2012-01-23 08:05:50 +00:00
|
|
|
|
|
|
|
skip_before_filter :require_account
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|