Skip to content

Instantly share code, notes, and snippets.

@dnlserrano
Last active August 29, 2015 13:57
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 dnlserrano/9722414 to your computer and use it in GitHub Desktop.
Save dnlserrano/9722414 to your computer and use it in GitHub Desktop.
Custom Token Authentication SessionsController
json.success true
json.data do
json.auth_token @user.authentication_token
end
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