Last active
August 29, 2015 14:09
-
-
Save ecarnevale/97f395e5169f9296869c to your computer and use it in GitHub Desktop.
This file contains hidden or 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 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