janko / rodauth-rails

Rails integration for Rodauth authentication framework
https://github.com/jeremyevans/rodauth
MIT License
599 stars 40 forks source link

append_info_to_payload #46

Closed dcalixto closed 3 years ago

dcalixto commented 3 years ago

@janko thank you very much for this gem, but after setup a simple api, and tried to create a account with react in the logs shows

NoMethodError (undefined method `append_info_to_payload' for # 17:55:43 api.1 | Did you mean? append_view_path):


  signUp() {
    fetch("/create-account", {
      method: "POST",
      headers: {
        Accept: "application/json",
        "Content-Type": "application/json",
      },
      body: JSON.stringify({
        data: {
          //username: this.state.username,
          login: this.state.login,
          password: this.state.password,
        },
      }),
    })
janko commented 3 years ago

Hmm, I'm not able to reproduce on Rails 6.1. When I look at the source code, ActionController::Instrumentation (which defines this method) is included into ActionController::API even on older versions of Rails, so I'm really not sure why it's not defined.

I do generally need to improve tests for the ActionController::API case, as I keep breaking the API-only integration 😞

dcalixto commented 3 years ago

@janko thank you very for your promptly reply! sorry my fault i forget that i'm using ActionController::Metal

so i had to

include ActionController::Instrumentation
 include ActionController::RequestForgeryProtection