Sha256: 12a3c16bd0be13bca92dbc246c6825bb9d883152c3876c5ac2da90064405340d

Contents?: true

Size: 807 Bytes

Versions: 1

Compression:

Stored size: 807 Bytes

Contents

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

  def show
    redirect_to_organization! if current_user.student_of? @organization
  end

  def join
    current_user.make_student_of! @invitation.course
    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.find_by_code params[:code]
    @organization = @invitation.organization
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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