sorcery icon indicating copy to clipboard operation
sorcery copied to clipboard

Using sorcery in an API-only rails app does not work

Open TheNeikos opened this issue 1 year ago • 3 comments

Configuration

  • Sorcery Version: 0.16.4
  • Ruby Version: 3.1.2
  • Framework: rails-7
  • Platform: linux-64_86

Expected Behavior

Sorcery should work out of the box with an API-only rails app

Actual Behavior

It errors with undefined local variable or method 'form_authenticity_token'.

Steps to Reproduce

  1. Make a rails API app
  2. Install sorcery
  3. Call login

TheNeikos avatar Nov 28 '22 17:11 TheNeikos

Potentially related issues (some closed): #242 #203

TheNeikos avatar Nov 28 '22 17:11 TheNeikos

Login method calls form_authenticity_token which is defined in request forgery protection concern. You can include it with:

include ActionController::RequestForgeryProtection

mladenilic avatar Nov 28 '22 18:11 mladenilic

@mladenilic saved me some work here, thanks!

Nitrodist avatar Feb 15 '24 15:02 Nitrodist