Skip to content

Instantly share code, notes, and snippets.

@ecarnevale
Last active August 29, 2015 14:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ecarnevale/97f395e5169f9296869c to your computer and use it in GitHub Desktop.
Save ecarnevale/97f395e5169f9296869c to your computer and use it in GitHub Desktop.
class ApplicationController < ActionController::Base
# protect_from_forgery
before_filter :authenticate_user_from_token!
before_filter :authenticate_user! #for classic Devise authentication
def authenticate_user_from_token!
access_token = params[:access_token].presence
if access_token
user = User.find_by_authentication_token(access_token.to_s)
if user
sign_in user, store: false
else
render :json => {:success => false, :message => "Authentication error"}, :status => 401
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment