Sha256: e868206d3d6c84b892fafb218e206a94237e53dd37ddfc0a2465468c45cb1dea

Contents?: true

Size: 809 Bytes

Versions: 8

Compression:

Stored size: 809 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.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.6.1 app/controllers/invitations_controller.rb
mumuki-laboratory-6.6.0 app/controllers/invitations_controller.rb
mumuki-laboratory-6.5.1 app/controllers/invitations_controller.rb
mumuki-laboratory-6.5.0 app/controllers/invitations_controller.rb
mumuki-laboratory-6.4.2 app/controllers/invitations_controller.rb
mumuki-laboratory-6.4.1 app/controllers/invitations_controller.rb
mumuki-laboratory-6.4.0 app/controllers/invitations_controller.rb
mumuki-laboratory-6.2.0 app/controllers/invitations_controller.rb