Sha256: bfcf3779879a346c6cbc71a1af9d91b546ff87de92d437c5010f2ed0988d7c65

Contents?: true

Size: 1.11 KB

Versions: 1

Compression:

Stored size: 1.11 KB

Contents

module Registrations::ControllerBase
  extend ActiveSupport::Concern

  include 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

        # TODO i think this might be redundant. we've added a hook into `session["user_return_to"]` in the
        # `invitations#accept` action and that might be enough to get them where they're supposed to be after
        # either creating a new account or signing into an existing account.
        handle_outstanding_invitation

        # if the user doesn't have a team at this point, create one.
        unless 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

1 entries across 1 versions & 1 rubygems

Version Path
bullet_train-1.0.6 app/controllers/concerns/registrations/controller_base.rb