Sha256: 762bb3d1b958561c58b68cfd8df9c2b820d81bf90d3c1b52e6c8b512a2c36717

Contents?: true

Size: 729 Bytes

Versions: 19

Compression:

Stored size: 729 Bytes

Contents

module Spotlight
  module Concerns
    ###
    # Mixin to be included into controllers that provides a
    # method to check if a particular user exists in the site
    module UserExistable
      def exists
        # note: the messages returned are not shown to users and really only useful for debug, hence no translation necessary
        #  app uses html status code to act on response
        if Spotlight::Engine.user_class.where(email: exists_params).present?
          render json: { message: 'User exists' }
        else
          render json: { message: 'User does not exist' }, status: :not_found
        end
      end

      protected

      def exists_params
        params.require(:user)
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
blacklight-spotlight-0.27.0 app/controllers/spotlight/concerns/user_existable.rb
blacklight-spotlight-0.26.1 app/controllers/spotlight/concerns/user_existable.rb
blacklight-spotlight-0.26.0 app/controllers/spotlight/concerns/user_existable.rb
blacklight-spotlight-0.25.0 app/controllers/spotlight/concerns/user_existable.rb
blacklight-spotlight-0.24.0 app/controllers/spotlight/concerns/user_existable.rb
blacklight-spotlight-0.23.0 app/controllers/spotlight/concerns/user_existable.rb
blacklight-spotlight-0.22.0 app/controllers/spotlight/concerns/user_existable.rb
blacklight-spotlight-0.21.0 app/controllers/spotlight/concerns/user_existable.rb
blacklight-spotlight-0.20.3 app/controllers/spotlight/concerns/user_existable.rb
blacklight-spotlight-0.20.2 app/controllers/spotlight/concerns/user_existable.rb
blacklight-spotlight-0.20.1 app/controllers/spotlight/concerns/user_existable.rb
blacklight-spotlight-0.20.0 app/controllers/spotlight/concerns/user_existable.rb
blacklight-spotlight-0.19.2 app/controllers/spotlight/concerns/user_existable.rb
blacklight-spotlight-0.19.1 app/controllers/spotlight/concerns/user_existable.rb
blacklight-spotlight-0.19.0 app/controllers/spotlight/concerns/user_existable.rb
blacklight-spotlight-0.18.0 app/controllers/spotlight/concerns/user_existable.rb
blacklight-spotlight-0.17.1 app/controllers/spotlight/concerns/user_existable.rb
blacklight-spotlight-0.17.0 app/controllers/spotlight/concerns/user_existable.rb
blacklight-spotlight-0.16.0 app/controllers/spotlight/concerns/user_existable.rb