You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a rails 5 api only app where I use devise_token_auth in my core engine. Unfortunately I cannot set parameters which I would allow to set in registration process
That is my engine application controller (RAILS_ROOT/engines/core/app/controllers/project_name/application_controller.rb):
module ProjectName
class ApplicationController < ActionController::Base
protect_from_forgery with: :null_session
include DeviseTokenAuth::Concerns::SetUserByToken
before_action :configure_permitted_parameters, if: :devise_controller?
protected
def configure_permitted_parameters
devise_parameter_sanitizer.permit(:sign_up, keys: [:name])
end
end
end
That is my user model inside my engine (RAILS_ROOT/engines/core/app/models/project_name/user.rb):
module ProjectName
class User < ApplicationRecord
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
include DeviseTokenAuth::Concerns::User
validates :name, presence: true
end
end
My routes are set to the following:
ProjectName::Core::Engine.routes.draw do
mount_devise_token_auth_for "ProjectName::User", at: "auth"
end
When requesting the route to create an user I get the following info in the log file:
Started POST "/auth" for ::1 at 2016-09-11 16:36:52 +0200
Processing by DeviseTokenAuth::RegistrationsController#create as JSON
Parameters: {"email"=>"[email protected]", "password"=>"[FILTERED]", "name"=>"Test User", "registration"=>{"email"=>"[email protected]", "password"=>"[FILTERED]", "name"=>"Test User"}}
Unpermitted parameters: name, registration
I realized that the before_action configure_permitted_parameters will not be called. But why? Even if I remove the if-condition the engine controller ignores the method.
How can I allow a users name in the registration process? Can anyone help me? Thanks in advance?
The text was updated successfully, but these errors were encountered:
I have a rails 5 api only app where I use devise_token_auth in my core engine. Unfortunately I cannot set parameters which I would allow to set in registration process
That is my engine application controller (
RAILS_ROOT/engines/core/app/controllers/project_name/application_controller.rb
):That is my user model inside my engine (
RAILS_ROOT/engines/core/app/models/project_name/user.rb
):My routes are set to the following:
When requesting the route to create an user I get the following info in the log file:
I realized that the before_action
configure_permitted_parameters
will not be called. But why? Even if I remove the if-condition the engine controller ignores the method.How can I allow a users name in the registration process? Can anyone help me? Thanks in advance?
The text was updated successfully, but these errors were encountered: