Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Api::V1::ApplicationController < ActionController::API
- include ActionController::HttpAuthentication::Token::ControllerMethods
- attr_reader :current_user
- before_filter :require_access_key
- before_filter :update_limit
- private
- def require_access_key
- authenticate_with_http_token do |key, options|
- @current_user = Token.find_by_key(key).account if Token.exists?(key: key)
- end
- end
- def update_limit
- access_token = @current_user.access_token
- previous_limit = access_token.limit
- access_token.update_attributes limit: previous_limit - 1
- end
- end
Add Comment
Please, Sign In to add comment