Last active
August 29, 2015 13:57
-
-
Save dnlserrano/9722414 to your computer and use it in GitHub Desktop.
Custom Token Authentication SessionsController
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
json.success true | |
json.data do | |
json.auth_token @user.authentication_token | |
end |
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 SessionsController < Devise::SessionsController | |
skip_before_filter :verify_authenticity_token, if: :json_request? | |
def create | |
warden.authenticate!(:scope => resource_name, :recall => "sessions#failure") | |
@user = current_user | |
# renders create.json.jbuilder | |
end | |
def destroy | |
# TODO | |
end | |
def failure | |
end | |
protected | |
def json_request? | |
request.format.json? | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment