Sha256: 22e06e94d3e6760eb01fe9e1e0c2e07bbe411771970c45732437a4a126453752

Contents?: true

Size: 972 Bytes

Versions: 11

Compression:

Stored size: 972 Bytes

Contents

module Spotlight
  module Concerns
    ###
    # Mixin to be included into controllers that provides an action which
    # allows admins and curators to invite users and assign them a role.
    module UserInvitable
      def invite
        # skip_invitation stops the immediate delivery of the invitation
        user = Spotlight::Engine.user_class.invite!(email: invite_params[:user], skip_invitation: true)
        role = Spotlight::Role.create(resource: exhibit_or_site, user: user, role: invite_params[:role])
        if role.save
          user.deliver_invitation # now deliver it when we have saved the role
          redirect_to :back, notice: t(:'helpers.submit.invite.invited')
        else
          redirect_to :back, alert: t(:'helpers.submit.role.batch_error')
        end
      end

      protected

      def invite_params
        params.permit(:user, :role)
      end

      def exhibit_or_site
        current_exhibit || @site
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
blacklight-spotlight-0.20.3 app/controllers/spotlight/concerns/user_invitable.rb
blacklight-spotlight-0.20.2 app/controllers/spotlight/concerns/user_invitable.rb
blacklight-spotlight-0.20.1 app/controllers/spotlight/concerns/user_invitable.rb
blacklight-spotlight-0.20.0 app/controllers/spotlight/concerns/user_invitable.rb
blacklight-spotlight-0.19.2 app/controllers/spotlight/concerns/user_invitable.rb
blacklight-spotlight-0.19.1 app/controllers/spotlight/concerns/user_invitable.rb
blacklight-spotlight-0.19.0 app/controllers/spotlight/concerns/user_invitable.rb
blacklight-spotlight-0.18.0 app/controllers/spotlight/concerns/user_invitable.rb
blacklight-spotlight-0.17.1 app/controllers/spotlight/concerns/user_invitable.rb
blacklight-spotlight-0.17.0 app/controllers/spotlight/concerns/user_invitable.rb
blacklight-spotlight-0.16.0 app/controllers/spotlight/concerns/user_invitable.rb