0

I have a rails application that used to just use the vanilla rails front end along with devise. I'm trying to change it to an api server with an angular front end, to that end I've decided to use devise_token_auth and ng-token-auth.

I can use them to sign in fine, but when I try to navigate to to any other page the cookies are being deleted.

I think the problem is that devise_token_auth isnt returning the access-token with the initial sign in.

I already have

config.middleware.insert_before 0, "Rack::Cors" do
  allow do
    origins '*'   #note to self, tighten this up, this isnt secure enough
    resource '*',
    :headers => :any,
    :methods => [:get, :post, :delete, :put, :options, :head],
    :expose  => ['access-token', 'expiry', 'token-type', 'uid', 'client'],
    :max_age => 0
  end
end

set up in my application.rb and

protect_from_forgery with: :null_session

in my application_controller.rb, which seem to be the most commonly reported solutions for this sort of problem but they arent working for me

Jarfis
  • 125
  • 11

1 Answers1

1

Turns out the problem was being caused by active_model_serializer. Found the solution here: https://github.com/lynndylanhurley/devise_token_auth/issues/600 , added serialization_scope :view_context to my application_controller.rb

Jarfis
  • 125
  • 11