Exemple #1
0
    def _process_new_user_data(request, new_web_user):
        """
        If available, this makes sure we apply any relevant user data
        :param request: HttpRequest
        :param new_web_user: WebUser
        :return:
        """
        user_data = get_new_sso_user_data_from_session(request)
        if not user_data:
            return

        phone_number = user_data['phone_number']
        if phone_number:
            new_web_user.phone_numbers.append(phone_number)
            new_web_user.save()

        if settings.IS_SAAS_ENVIRONMENT:
            track_workflow(new_web_user.username,
                           "Requested New Account via SSO", {
                               'environment': settings.SERVER_ENVIRONMENT,
                           })
            track_workflow(
                new_web_user.username, "Persona Field Filled Out via SSO", {
                    'personachoice': user_data['persona'],
                    'personaother': user_data['persona_other'],
                })
            track_web_user_registration_hubspot(
                request,
                new_web_user,
                user_data['additional_hubspot_data'],
            )
Exemple #2
0
    def _process_new_user_data(request, new_web_user, async_signup):
        """
        If available, this makes sure we apply any relevant user data
        :param request: HttpRequest
        :param new_web_user: WebUser
        :param async_signup: AsyncSignupRequest
        """
        if not async_signup:
            if settings.IS_SAAS_ENVIRONMENT:
                track_workflow(
                    new_web_user.username,
                    "Requested New Account via SSO (Bypassed Signup Form)",
                    {
                        'environment': settings.SERVER_ENVIRONMENT,
                    }
                )
            return

        if async_signup.invitation:
            return

        if async_signup.phone_number:
            new_web_user.phone_numbers.append(async_signup.phone_number)
            new_web_user.save()

        if settings.IS_SAAS_ENVIRONMENT:
            track_workflow(
                new_web_user.username,
                "Requested New Account via SSO",
                {
                    'environment': settings.SERVER_ENVIRONMENT,
                }
            )
            if async_signup.persona:
                track_workflow(
                    new_web_user.username,
                    "Persona Field Filled Out via SSO",
                    {
                        'personachoice': async_signup.persona,
                        'personaother': async_signup.persona_other,
                    }
                )
                track_web_user_registration_hubspot(
                    request,
                    new_web_user,
                    async_signup.additional_hubspot_data,
                )
            else:
                track_workflow(
                    new_web_user.username,
                    "New User created through SSO, but Persona info missing"
                )
Exemple #3
0
    def _create_new_account(self, reg_form, additional_hubspot_data=None):
        activate_new_user_via_reg_form(reg_form,
                                       created_by=None,
                                       created_via=USER_CHANGE_VIA_WEB,
                                       ip=get_ip(self.request))
        new_user = authenticate(username=reg_form.cleaned_data['email'],
                                password=reg_form.cleaned_data['password'],
                                request=self.request)
        web_user = WebUser.get_by_username(new_user.username, strict=True)

        if 'phone_number' in reg_form.cleaned_data and reg_form.cleaned_data[
                'phone_number']:
            web_user.phone_numbers.append(
                reg_form.cleaned_data['phone_number'])
            web_user.save()

        if settings.IS_SAAS_ENVIRONMENT:
            email = new_user.email

            # registration analytics
            # only do anything with this in a SAAS environment

            persona = reg_form.cleaned_data['persona']
            persona_other = reg_form.cleaned_data['persona_other']

            track_workflow(email, "Requested New Account", {
                'environment': settings.SERVER_ENVIRONMENT,
            })
            track_workflow(email, "Persona Field Filled Out", {
                'personachoice': persona,
                'personaother': persona_other,
            })

            if not additional_hubspot_data:
                additional_hubspot_data = {}
            additional_hubspot_data.update({
                'buyer_persona':
                persona,
                'buyer_persona_other':
                persona_other,
            })
            track_web_user_registration_hubspot(self.request, web_user,
                                                additional_hubspot_data)
            if not persona or (persona == 'Other' and not persona_other):
                # There shouldn't be many instances of this.
                _assert = soft_assert('@'.join(['bbuczyk', 'dimagi.com']),
                                      exponential_backoff=False)
                _assert(
                    False, "[BAD PERSONA DATA] Persona fields during "
                    "login submitted empty. User: {}".format(email))

        login(self.request, new_user)
Exemple #4
0
    def _create_new_account(self, reg_form, additional_hubspot_data=None):
        activate_new_user(reg_form, ip=get_ip(self.request))
        new_user = authenticate(
            username=reg_form.cleaned_data['email'],
            password=reg_form.cleaned_data['password']
        )
        web_user = WebUser.get_by_username(new_user.username, strict=True)

        if 'phone_number' in reg_form.cleaned_data and reg_form.cleaned_data['phone_number']:
            web_user.phone_numbers.append(reg_form.cleaned_data['phone_number'])
            web_user.save()

        if settings.IS_SAAS_ENVIRONMENT:
            email = new_user.email

            # registration analytics
            # only do anything with this in a SAAS environment

            persona = reg_form.cleaned_data['persona']
            persona_other = reg_form.cleaned_data['persona_other']

            track_workflow(email, "Requested New Account", {
                'environment': settings.SERVER_ENVIRONMENT,
            })
            track_workflow(email, "Persona Field Filled Out", {
                'personachoice': persona,
                'personaother': persona_other,
            })

            if not additional_hubspot_data:
                additional_hubspot_data = {}
            additional_hubspot_data.update({
                'buyer_persona': persona,
                'buyer_persona_other': persona_other,
            })
            track_web_user_registration_hubspot(
                self.request,
                web_user,
                additional_hubspot_data
            )
            if not persona or (persona == 'Other' and not persona_other):
                # There shouldn't be many instances of this.
                _assert = soft_assert('@'.join(['bbuczyk', 'dimagi.com']), exponential_backoff=False)
                _assert(
                    False,
                    "[BAD PERSONA DATA] Persona fields during "
                    "login submitted empty. User: {}".format(email)
                )

        login(self.request, new_user)