Sha256: 9532b10fb91f2ec4327a901e59131cea430fd5a842af4229f4ee6aeb52c5b974

Contents?: true

Size: 1.08 KB

Versions: 11

Compression:

Stored size: 1.08 KB

Contents

module Registrations::ControllerBase
  extend ActiveSupport::Concern

  included do
    def new
      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
        # if the user doesn't have a team at this point, create one.
        # If the user is accepting an invitation, then the user's current_team is populated
        # with the information attached to their invitation via `@invitation.accept_for` later on,
        # so we don't have to create a default team for them here.
        unless current_user.teams.any? || session[:invitation_uuid].present?
          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

11 entries across 11 versions & 1 rubygems

Version Path
bullet_train-1.1.10 app/controllers/concerns/registrations/controller_base.rb
bullet_train-1.1.9 app/controllers/concerns/registrations/controller_base.rb
bullet_train-1.1.7 app/controllers/concerns/registrations/controller_base.rb
bullet_train-1.1.6 app/controllers/concerns/registrations/controller_base.rb
bullet_train-1.1.5 app/controllers/concerns/registrations/controller_base.rb
bullet_train-1.1.4 app/controllers/concerns/registrations/controller_base.rb
bullet_train-1.1.3 app/controllers/concerns/registrations/controller_base.rb
bullet_train-1.1.2 app/controllers/concerns/registrations/controller_base.rb
bullet_train-1.1.1 app/controllers/concerns/registrations/controller_base.rb
bullet_train-1.1.0 app/controllers/concerns/registrations/controller_base.rb
bullet_train-1.0.99 app/controllers/concerns/registrations/controller_base.rb