Sha256: 08f5f889f5f496f018db59d55967b05917b601b636f5077e1478c3dd02b9e045

Contents?: true

Size: 1.2 KB

Versions: 142

Compression:

Stored size: 1.2 KB

Contents

module Registrations::ControllerBase
  extend ActiveSupport::Concern

  included do
    def new
      # We have to set the session here because Safari wouldn't save it on a redirect to this URL.
      if params[:invitation_uuid]
        session[:invitation_uuid] = params[:invitation_uuid]
        session["user_return_to"] = accept_account_invitation_path(params[:invitation_uuid])
      end

      if invitation_only?
        unless session[:invitation_uuid] || session[:invitation_key]
          return redirect_to root_path
        end
      end

      # do all the regular devise stuff.
      super
    end

    def create
      # do all the regular devise stuff first.
      super

      # if current_user is defined, that means they were successful registering.
      if current_user
        # Don't create a default team if they're being invited to another team.
        # Don't create a default team if they have another one for any reason.
        unless session[:invitation_uuid].present? || current_user.teams.any?
          current_user.create_default_team
        end

        # send the welcome email.
        current_user.send_welcome_email unless current_user.email_is_oauth_placeholder?
      end
    end
  end
end

Version data entries

142 entries across 142 versions & 1 rubygems

Version Path
bullet_train-1.4.7 app/controllers/concerns/registrations/controller_base.rb
bullet_train-1.4.6 app/controllers/concerns/registrations/controller_base.rb
bullet_train-1.4.5 app/controllers/concerns/registrations/controller_base.rb
bullet_train-1.4.4 app/controllers/concerns/registrations/controller_base.rb
bullet_train-1.4.3 app/controllers/concerns/registrations/controller_base.rb
bullet_train-1.4.2 app/controllers/concerns/registrations/controller_base.rb
bullet_train-1.4.1 app/controllers/concerns/registrations/controller_base.rb
bullet_train-1.4.0 app/controllers/concerns/registrations/controller_base.rb
bullet_train-1.3.25 app/controllers/concerns/registrations/controller_base.rb
bullet_train-1.3.24 app/controllers/concerns/registrations/controller_base.rb
bullet_train-1.3.23 app/controllers/concerns/registrations/controller_base.rb
bullet_train-1.3.22 app/controllers/concerns/registrations/controller_base.rb
bullet_train-1.3.21 app/controllers/concerns/registrations/controller_base.rb
bullet_train-1.3.20 app/controllers/concerns/registrations/controller_base.rb
bullet_train-1.3.19 app/controllers/concerns/registrations/controller_base.rb
bullet_train-1.3.18 app/controllers/concerns/registrations/controller_base.rb
bullet_train-1.3.17 app/controllers/concerns/registrations/controller_base.rb
bullet_train-1.3.16 app/controllers/concerns/registrations/controller_base.rb
bullet_train-1.3.15 app/controllers/concerns/registrations/controller_base.rb
bullet_train-1.3.14 app/controllers/concerns/registrations/controller_base.rb