Last active
October 18, 2017 01:40
Revisions
-
dnlserrano revised this gist
Mar 24, 2014 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -16,6 +16,7 @@ def create def destroy @user = current_user @user.authentication_token = nil @user.save # renders destroy.json.jbuilder end -
dnlserrano revised this gist
Mar 23, 2014 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -20,6 +20,7 @@ def destroy end def failure # renders failure.json.jbuilder end protected -
dnlserrano created this gist
Mar 23, 2014 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,5 @@ json.success true json.data do json.auth_token @user.authentication_token json.message "login successful" 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,4 @@ json.success true json.data do json.message "logout successful" 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,4 @@ json.sucess false json.data do json.message "login failed" 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,30 @@ class SessionsController < Devise::SessionsController skip_before_filter :verify_authenticity_token, if: :json_request? acts_as_token_authentication_handler_for User skip_before_filter :authenticate_entity_from_token! skip_before_filter :authenticate_entity! before_filter :authenticate_entity_from_token!, :only => [:destroy] before_filter :authenticate_entity!, :only => [:destroy] def create warden.authenticate!(:scope => resource_name, :recall => "sessions#failure") @user = current_user # renders destroy.json.jbuilder end def destroy @user = current_user @user.authentication_token = nil # renders destroy.json.jbuilder end def failure end protected def json_request? request.format.json? end end