Sha256: 312f3330c92cc615d953e116a7e1537a3729fbb1eb5ea0b3519c9cac89f4ca20

Contents?: true

Size: 814 Bytes

Versions: 8

Compression:

Stored size: 814 Bytes

Contents

class InvitationsController < ApplicationController
  before_action :authenticate!
  before_action :set_invitation!

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

  def join
    current_user.accept_invitation! @invitation
    current_user.update! user_params
    current_user.notify!
    redirect_to_organization!
  end

  def authorize_if_private!
    # This controller must never be authenticated
  end

  private

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

  def user_params
    params.require(:user).permit(:name, :first_name, :last_name, :email)
  end

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

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
mumuki-laboratory-6.7.7 app/controllers/invitations_controller.rb
mumuki-laboratory-6.7.6 app/controllers/invitations_controller.rb
mumuki-laboratory-6.7.5 app/controllers/invitations_controller.rb
mumuki-laboratory-6.7.4 app/controllers/invitations_controller.rb
mumuki-laboratory-6.7.3 app/controllers/invitations_controller.rb
mumuki-laboratory-6.7.2 app/controllers/invitations_controller.rb
mumuki-laboratory-6.7.1 app/controllers/invitations_controller.rb
mumuki-laboratory-6.7.0 app/controllers/invitations_controller.rb