Sha256: a86211484a77a7cce272afcf6acb9f2198ea8777dd451d26eb44877ac4131e21

Contents?: true

Size: 1.73 KB

Versions: 4

Compression:

Stored size: 1.73 KB

Contents

module MnoEnterprise::Concerns::Controllers::OrgInvitesController
  extend ActiveSupport::Concern

  #==================================================================
  # Included methods
  #==================================================================
  # 'included do' causes the included code to be evaluated in the
  # context where it is included rather than being executed in the module's context
  included do
    before_filter :authenticate_user!
  end

  #==================================================================
  # Class methods
  #==================================================================
  module ClassMethods
    # def some_class_method
    #   'some text'
    # end
  end

  #==================================================================
  # Instance methods
  #==================================================================
  # GET /org_invites/1?token=HJuiofjpa45A73255a74F534FDfds
  # TODO: improve integration with new frontends
  def show
    @current_user = current_user
    @org_invite = MnoEnterprise::OrgInvite.active.where(id: params[:id], token: params[:token]).first
    redirect_path = mnoe_home_path

    if @org_invite && !@org_invite.expired? && @org_invite.accept!(current_user)
      redirect_path += "#/?dhbRefId=#{ @org_invite.organization.id}"
      message = { notice: "You are now part of #{@org_invite.organization.name}" }
      yield(:success, @org_invite) if block_given?
    elsif @org_invite && @org_invite.expired?
      message = { alert: "It looks like this invite has expired. Please ask your company administrator to resend the invite." }
    else
      message = { alert: "Unfortunately, this invite does not seem to be valid." }
    end

    redirect_to redirect_path, message
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mno-enterprise-api-3.0.1 lib/mno_enterprise/concerns/controllers/org_invites_controller.rb
mno-enterprise-api-2.0.1 lib/mno_enterprise/concerns/controllers/org_invites_controller.rb
mno-enterprise-api-3.0.0 lib/mno_enterprise/concerns/controllers/org_invites_controller.rb
mno-enterprise-api-2.0.0 lib/mno_enterprise/concerns/controllers/org_invites_controller.rb