Save 36% for Black Friday! Learn more

Bill Tihen

Joined

60 Experience
0 Lessons Completed
0 Questions Solved

Activity

I will do that next - for better understanding indeed. I am mostly interested in the Devise JWT - since that is what I use most of the time anyway, but the series is interesting so I figured it can't hurt to debug a little.

Solution for Rails 6

  • To fix the autoloading problem on config and the error (uninitialized constant Knock) while trying to use
    change the line in: config/application.rb
    from
    config.load_defaults 6.0
    to
    config.load_defaults 6.0 and config.autoloader = :classic

  • To fix the problem Can't verify CSRF token authenticity.
    include skip_before_action :verify_authenticity_token in the file:
    app/controllers/api/v1/user_token_controller.rb
    so the controller needs to look like:

    class Api::V1::UserTokenController < Knock::AuthTokenController
    skip_before_action :verify_authenticity_token
    def entity_name
    'User'
    end
    end
    

AFTER these two fixes:
curl --data "auth[email][email protected]&auth[password]=*******" http://localhost:3000/api/v1/user_token
works!

Looks like knock has an eager_load problem with Rails 6 & knock is no longer being maintained.

Posted in Issue with devise

I am having the same error (with Devise within an engine) - can you say more about your solution?

I think I will try to override the method:

# app/config/routes.rb
# devise_for :users, :controllers => {:registrations => "registrations"}

# app/controllers/registrations_controller.rb
class RegistrationsController < Devise::RegistrationsController
  protected
  def after_sign_in_path_for(resource)
    # cofirm_email_sent_path
  end

Something like that - a lot like the recommendations for confirmable: https://github.com/plataformatec/devise/wiki/How-To:-Add-:confirmable-to-Users

so I looked at the controller for devise registrations:
https://github.com/plataformatec/devise/blob/master/app/controllers/devise/registrations_controller.rb)

Did you get an answer to this? I'm looking for the same information.

logo Created with Sketch.

Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

© 2020 GoRails, LLC. All rights reserved.