gonzalo-bulnes/simple_token_authentication

When trying to fallback to normal devise authentication, it is showing filter chain halted as authenticate_user_from_token! rendered or redirected.

Opened this issue · 0 comments

I have a RoomsController with following setup:

 module Api
    module V1
      class Api::V1::Member::RoomsController < Member::BaseController
        acts_as_token_authentication_handler_for SpreeUser, fallback: :devise
      
        def create
            # Come here only when authenticated through token.
        end
      end
    end
end

On my ApplicationController I have got the authenticate_spree_user method opened to meet my feature criteria.

def authenticate_spree_user!(opts={})
    if spree_user_signed_in? || request.controller_class == UserSessionsController
      super
    else request.controller_class == Api::V1::Member::RoomsController
      (session[:return_to] = request.fullpath) if request.get?
      redirect_to login_path
  end
end

However I am getting Filter chain halted as :authenticate_spree_user_from_token! rendered or redirected from every request I send to api with failure authentication. Below is the error log:

Redirected to http://sampleapp:3000/login
Filter chain halted as :authenticate_spree_user_from_token! rendered or redirected
Completed 200 OK in 2475ms (ActiveRecord: 0.9ms)