Skip to content

Instantly share code, notes, and snippets.

@sccheruku
Created January 30, 2015 02:43
Show Gist options
  • Save sccheruku/4b743148711a604cb0c0 to your computer and use it in GitHub Desktop.
Save sccheruku/4b743148711a604cb0c0 to your computer and use it in GitHub Desktop.
class BaseApiController < ApplicationController before_filter :parse_request, :authenticate_user_from_token! private def authenticate_user_from_token! if !@json['api_token'] render nothing: true, status: :unauthorized else @user = nil User.find_each do |u| if Devise.secure_compare(u.api_token, @json['api_token']) @user = u end end end end def parse_request @json = JSON.parse(request.body.read) end end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment