Sha256: 4b2dcef74f0d6718616f1f96a019e5bd6509093d65a0d8b6bdd4194344e38411

Contents?: true

Size: 920 Bytes

Versions: 1

Compression:

Stored size: 920 Bytes

Contents

class InvitationsController < ApplicationController
  include WithUserParams

  before_action :authenticate!
  before_action :set_invitation!
  before_action :set_user!

  skip_before_action :validate_user_profile!
  skip_before_action :authorize_if_private!
  skip_before_action :validate_active_organization!

  def show
    redirect_to_organization! if current_user.student_of? @invitation.course
  end

  def join
    current_user.accept_invitation! @invitation
    current_user.update_and_notify! user_params
    redirect_to_organization!
  end

  private

  def redirect_to_organization!
    redirect_to Mumukit::Platform.laboratory.organic_url(@organization)
  end

  def permissible_params
    super + [:email, :name]
  end

  def set_invitation!
    @invitation = Invitation.locate!(params[:code]).unexpired
    @organization = @invitation.organization
  end

  def set_user!
    @user = current_user
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mumuki-laboratory-8.0.0 app/controllers/invitations_controller.rb