Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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