lib/generators/socials/devise_generator.rb
# Add Devise auth & validations to the Main top Controller
Add Devise auth & validations to the Main top Controller
Add Devise auth & validations to the Main top Controller
def update_application_controller
        inject_into_file 'app/controllers/application_controller.rb', after: "protect_from_forgery with: :exception\n" do <<-'RUBY'
  before_action :authenticate_or_token
  protected
    def configure_permitted_parameters
      devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(:locale, :name, :username, :email, :password, :password_confirmation, :role, :remember_me) }
      devise_parameter_sanitizer.for(:sign_in) { |u| u.permit(:login, :username, :email, :password, :remember_me) }
      devise_parameter_sanitizer.for(:account_update) { |u| u.permit(:username, :email, :password, :password_confirmation, :current_password, :role) }
      I18n.locale = @current_user.locale || I18n.default_locale unless @current_user.nil?
    end
    # Validate user session if is not API call
    def authenticate_or_token
      authenticate_user! if params[:controller].index('api').nil? && request.fullpath != root_path
      @current_user = current_user if @current_user.nil?
    end
          RUBY
        end
      end
def update_application_controller inject_into_file 'app/controllers/application_controller.rb' , after : "protect_from_forgery with: :exception\n" do <<-'RUBY' 
  before_action :authenticate_or_token

  protected
    def configure_permitted_parameters
      devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(:locale, :name, :username, :email, :password, :password_confirmation, :role, :remember_me) }
      devise_parameter_sanitizer.for(:sign_in) { |u| u.permit(:login, :username, :email, :password, :remember_me) }
      devise_parameter_sanitizer.for(:account_update) { |u| u.permit(:username, :email, :password, :password_confirmation, :current_password, :role) }
      I18n.locale = @current_user.locale || I18n.default_locale unless @current_user.nil?
    end

    # Validate user session if is not API call
    def authenticate_or_token
      authenticate_user! if params[:controller].index('api').nil? && request.fullpath != root_path
      @current_user = current_user if @current_user.nil?
    end

           RUBY end end
Add Devise auth & validations to the Main top Controller
Add Devise auth & validations to the Main top Controller