Exemplo n.º 1
0
def confirm_domain(request, guid=None):
    error = None
    # Did we get a guid?
    if guid is None:
        error = _(
            'An account activation key was not provided.  If you think this '
            'is an error, please contact the system administrator.')

    # Does guid exist in the system?
    else:
        req = RegistrationRequest.get_by_guid(guid)
        if not req:
            error = _(
                'The account activation key "%s" provided is invalid. If you '
                'think this is an error, please contact the system '
                'administrator.') % guid

    if error is not None:
        context = {
            'message_body': error,
            'current_page': {
                'page_name': 'Account Not Activated'
            },
        }
        return render(request, 'registration/confirmation_error.html', context)

    requested_domain = Domain.get_by_name(req.domain)

    # Has guid already been confirmed?
    if requested_domain.is_active:
        assert (req.confirm_time is not None and req.confirm_ip is not None)
        messages.success(
            request, 'Your account %s has already been activated. '
            'No further validation is required.' % req.new_user_username)
        return HttpResponseRedirect(
            reverse("dashboard_default", args=[requested_domain]))

    # Set confirm time and IP; activate domain and new user who is in the
    req.confirm_time = datetime.utcnow()
    req.confirm_ip = get_ip(request)
    req.save()
    requested_domain.is_active = True
    requested_domain.save()
    requesting_user = WebUser.get_by_username(req.new_user_username)

    send_new_request_update_email(requesting_user,
                                  get_ip(request),
                                  requested_domain.name,
                                  is_confirming=True)

    messages.success(
        request,
        'Your account has been successfully activated.  Thank you for taking '
        'the time to confirm your email address: %s.' %
        (requesting_user.username))
    track_workflow(requesting_user.email, "Confirmed new project")
    track_confirmed_account_on_hubspot.delay(requesting_user)
    return HttpResponseRedirect(
        reverse("dashboard_default", args=[requested_domain]))
Exemplo n.º 2
0
def confirm_domain(request, guid=None):
    error = None
    # Did we get a guid?
    if guid is None:
        error = _('An account activation key was not provided.  If you think this '
                  'is an error, please contact the system administrator.')

    # Does guid exist in the system?
    else:
        req = RegistrationRequest.get_by_guid(guid)
        if not req:
            error = _('The account activation key "%s" provided is invalid. If you '
                      'think this is an error, please contact the system '
                      'administrator.') % guid

    if error is not None:
        context = {
            'message_body': error,
            'current_page': {'page_name': 'Account Not Activated'},
        }
        return render(request, 'registration/confirmation_error.html', context)

    requested_domain = Domain.get_by_name(req.domain)

    # Has guid already been confirmed?
    if requested_domain.is_active:
        assert(req.confirm_time is not None and req.confirm_ip is not None)
        messages.success(request, 'Your account %s has already been activated. '
            'No further validation is required.' % req.new_user_username)
        return HttpResponseRedirect(reverse("dashboard_default", args=[requested_domain]))

    # Set confirm time and IP; activate domain and new user who is in the
    req.confirm_time = datetime.utcnow()
    req.confirm_ip = get_ip(request)
    req.save()
    requested_domain.is_active = True
    requested_domain.save()
    requesting_user = WebUser.get_by_username(req.new_user_username)

    send_new_request_update_email(requesting_user, get_ip(request), requested_domain.name, is_confirming=True)

    messages.success(request,
            'Your account has been successfully activated.  Thank you for taking '
            'the time to confirm your email address: %s.'
        % (requesting_user.username))
    track_workflow(requesting_user.email, "Confirmed new project")
    track_confirmed_account_on_hubspot.delay(requesting_user)
    url = reverse("dashboard_default", args=[requested_domain])

    # If user already created an app (via prelogin demo), send them there
    apps = get_apps_in_domain(requested_domain.name, include_remote=False)
    if len(apps) == 1:
        app = apps[0]
        if len(app.modules) == 1 and len(app.modules[0].forms) == 1:
            url = reverse('form_source', args=[requested_domain.name, app.id, 0, 0])

    return HttpResponseRedirect(url)
Exemplo n.º 3
0
def confirm_domain(request, guid=None):
    error = None
    # Did we get a guid?
    if guid is None:
        error = _('An account activation key was not provided.  If you think this '
                  'is an error, please contact the system administrator.')

    # Does guid exist in the system?
    else:
        req = RegistrationRequest.get_by_guid(guid)
        if not req:
            error = _('The account activation key "%s" provided is invalid. If you '
                      'think this is an error, please contact the system '
                      'administrator.') % guid

    if error is not None:
        context = {
            'message_title': _('Account not activated'),
            'message_subtitle': _('Email not yet confirmed'),
            'message_body': error,
        }
        return render(request, 'registration/confirmation_error.html', context)

    requested_domain = Domain.get_by_name(req.domain)

    # Has guid already been confirmed?
    if requested_domain.is_active:
        assert(req.confirm_time is not None and req.confirm_ip is not None)
        messages.success(request, 'Your account %s has already been activated. '
            'No further validation is required.' % req.new_user_username)
        return HttpResponseRedirect(reverse("dashboard_default", args=[requested_domain]))

    # Set confirm time and IP; activate domain and new user who is in the
    req.confirm_time = datetime.utcnow()
    req.confirm_ip = get_ip(request)
    req.save()
    requested_domain.is_active = True
    requested_domain.save()
    requesting_user = WebUser.get_by_username(req.new_user_username)

    send_new_request_update_email(requesting_user, get_ip(request), requested_domain.name, is_confirming=True)

    messages.success(request,
            'Your account has been successfully activated.  Thank you for taking '
            'the time to confirm your email address: %s.'
        % (requesting_user.username))
    track_workflow(requesting_user.email, "Confirmed new project")
    track_confirmed_account_on_hubspot.delay(requesting_user)
    return HttpResponseRedirect(reverse("dashboard_default", args=[requested_domain]))
Exemplo n.º 4
0
def confirm_domain(request, guid=''):
    with CriticalSection(['confirm_domain_' + guid]):
        error = None
        # Did we get a guid?
        if not guid:
            error = _('An account activation key was not provided.  If you think this '
                      'is an error, please contact the system administrator.')

        # Does guid exist in the system?
        else:
            req = RegistrationRequest.get_by_guid(guid)
            if not req:
                error = _('The account activation key "%s" provided is invalid. If you '
                          'think this is an error, please contact the system '
                          'administrator.') % guid

        if error is not None:
            context = {
                'message_body': error,
                'current_page': {'page_name': 'Account Not Activated'},
            }
            return render(request, 'registration/confirmation_error.html', context)

        requested_domain = Domain.get_by_name(req.domain)
        view_name = "dashboard_default"
        view_args = [requested_domain.name]
        if not domain_has_apps(req.domain):
            if False and settings.IS_SAAS_ENVIRONMENT and domain_is_on_trial(req.domain):
                view_name = "app_from_template"
                view_args.append("appcues")
            else:
                view_name = "default_new_app"

        # Has guid already been confirmed?
        if requested_domain.is_active:
            assert(req.confirm_time is not None and req.confirm_ip is not None)
            messages.success(request, 'Your account %s has already been activated. '
                'No further validation is required.' % req.new_user_username)
            return HttpResponseRedirect(reverse(view_name, args=view_args))

        # Set confirm time and IP; activate domain and new user who is in the
        req.confirm_time = datetime.utcnow()
        req.confirm_ip = get_ip(request)
        req.save()
        requested_domain.is_active = True
        requested_domain.save()
        requesting_user = WebUser.get_by_username(req.new_user_username)

        send_new_request_update_email(requesting_user, get_ip(request), requested_domain.name, is_confirming=True)

        messages.success(request,
                'Your account has been successfully activated.  Thank you for taking '
                'the time to confirm your email address: %s.'
            % (requesting_user.username))
        track_workflow(requesting_user.email, "Confirmed new project")
        track_confirmed_account_on_hubspot.delay(requesting_user)
        request.session['CONFIRM'] = True

        if settings.IS_SAAS_ENVIRONMENT:
            # For AppCues v3, land new user in Web Apps
            view_name = get_cloudcare_urlname(requested_domain.name)
        return HttpResponseRedirect(reverse(view_name, args=view_args))
Exemplo n.º 5
0
def confirm_domain(request, guid=None):
    # Did we get a guid?
    vals = {}
    if guid is None:
        vals['message_title'] = _('Missing Activation Key')
        vals['message_subtitle'] = _('Account Activation Failed')
        vals['message_body'] = _(
            'An account activation key was not provided.  If you think this '
            'is an error, please contact the system administrator.'
        )
        vals['is_error'] = True
        return render(request, 'registration/confirmation_complete.html', vals)

    # Does guid exist in the system?
    req = RegistrationRequest.get_by_guid(guid)
    if not req:
        vals['message_title'] = _('Invalid Activation Key')
        vals['message_subtitle'] = _('Account Activation Failed')
        vals['message_body'] = _(
            'The account activation key "%s" provided is invalid. If you '
            'think this is an error, please contact the system '
            'administrator.'
        ) % guid
        vals['is_error'] = True
        return render(request, 'registration/confirmation_complete.html', vals)

    requested_domain = Domain.get_by_name(req.domain)
    context = get_domain_context(requested_domain.domain_type)
    context['requested_domain'] = req.domain

    # Has guid already been confirmed?
    if requested_domain.is_active:
        assert(req.confirm_time is not None and req.confirm_ip is not None)
        context['message_title'] = _('Already Activated')
        context['message_body'] = _(
            'Your account %s has already been activated. No further '
            'validation is required.'
        ) % req.new_user_username
        context['is_error'] = False
        return render(request, 'registration/confirmation_complete.html',
                context)

    # Set confirm time and IP; activate domain and new user who is in the
    req.confirm_time = datetime.utcnow()
    req.confirm_ip = get_ip(request)
    req.save()
    requested_domain.is_active = True
    requested_domain.save()
    requesting_user = WebUser.get_by_username(req.new_user_username)

    send_new_request_update_email(requesting_user, get_ip(request), requested_domain.name, is_confirming=True)

    context['message_title'] = _('Account Confirmed')
    context['message_subtitle'] = _(
        'Thank you for activating your account, %s!'
    ) % requesting_user.first_name
    context['message_body'] = _(
        'Your account has been successfully activated.  Thank you for taking '
        'the time to confirm your email address: %s.'
    ) % requesting_user.username
    context['is_error'] = False
    context['valid_confirmation'] = True
    track_confirmed_account_on_hubspot.delay(requesting_user)
    return render(request, 'registration/confirmation_complete.html', context)