Sha256: af46eae69a22c8c084b95c64275fbd63074f4b490b0636ca19a882be32d90774

Contents?: true

Size: 1017 Bytes

Versions: 9

Compression:

Stored size: 1017 Bytes

Contents

module DeviseInvitable
  module ParameterSanitizer
    if defined?(Devise::BaseSanitizer)
      def invite
        permit self.for(:invite)
      end

      def accept_invitation
        permit self.for(:accept_invitation)
      end
    end

    private

    if defined?(Devise::BaseSanitizer)
      def permit(keys)
        default_params.permit(*Array(keys))
      end

      def attributes_for(kind)
        case kind
        when :invite
          resource_class.respond_to?(:invite_key_fields) ? resource_class.invite_key_fields : []
        when :accept_invitation
          [:password, :password_confirmation, :invitation_token]
        else
          super
        end
      end
    else
      def initialize(resource_class, resource_name, params)
        super
        permit(:invite, keys: (resource_class.respond_to?(:invite_key_fields) ? resource_class.invite_key_fields : []) )
        permit(:accept_invitation, keys: [:password, :password_confirmation, :invitation_token] )
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
devise_invitable-2.0.0 lib/devise_invitable/parameter_sanitizer.rb
devise_invitable-1.7.5 lib/devise_invitable/parameter_sanitizer.rb
devise_invitable-1.7.4 lib/devise_invitable/parameter_sanitizer.rb
devise_invitable-1.7.3 lib/devise_invitable/parameter_sanitizer.rb
devise_invitable-1.7.2 lib/devise_invitable/parameter_sanitizer.rb
devise_invitable-1.7.1 lib/devise_invitable/parameter_sanitizer.rb
devise_invitable-1.7.0 lib/devise_invitable/parameter_sanitizer.rb
devise_invitable-1.6.1 lib/devise_invitable/parameter_sanitizer.rb
devise_invitable-1.6.0 lib/devise_invitable/parameter_sanitizer.rb