@require_GET
def redirect_to_default(req, domain=None):
    if not req.user.is_authenticated():
        if domain != None:
            url = reverse('domain_login', args=[domain])
        else:
            if settings.ENABLE_PRELOGIN_SITE:
                try:
                    from corehq.apps.prelogin.views import HomePublicView
                    url = reverse(HomePublicView.urlname)
                except __HOLE__:
                    # this happens when the prelogin app is not included.
                    url = reverse('landing_page')
            else:
                url = reverse('landing_page')
    elif domain and _two_factor_needed(domain, req):
        return TemplateResponse(
            request=req,
            template='two_factor/core/otp_required.html',
            status=403,
        )
    else:
        if domain:
            domain = normalize_domain_name(domain)
            domains = [Domain.get_by_name(domain)]
        else:
            domains = Domain.active_for_user(req.user)
        if 0 == len(domains) and not req.user.is_superuser:
            return redirect('registration_domain')
        elif 1 == len(domains):
            if domains[0]:
                domain = domains[0].name

                if (req.couch_user.is_commcare_user()
                    and not is_mobile_worker_with_report_access(
                        req.couch_user, domain)):
                    url = reverse("cloudcare_main", args=[domain, ""])
                else:
                    from corehq.apps.dashboard.views import dashboard_default
                    return dashboard_default(req, domain)

            else:
                raise Http404
        else:
            url = settings.DOMAIN_SELECT_URL
    return HttpResponseRedirect(url)
dataset/ETHPy150Open dimagi/commcare-hq/corehq/apps/hqwebapp/views.py/redirect_to_default