Created
January 30, 2015 02:43
-
-
Save sccheruku/4b743148711a604cb0c0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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