def login(request, multipass=False, template_name='registration/login.html',
          redirect_field_name=REDIRECT_FIELD_NAME,
          authentication_form=AuthenticationForm):
    """Displays the login form and handles the login action."""

    redirect_to = request.REQUEST.get(redirect_field_name, '')

    tender_url = getattr(settings, 'TENDER_URL', None)
    if not redirect_to or ' ' in redirect_to:
        redirect_to = settings.LOGIN_REDIRECT_URL
    # Heavier security check -- redirects to http://example.com should
    # not be allowed, but things like /view/?param=http://example.com
    # should be allowed. This regex checks if there is a '//' *before* a
    # question mark. Unless of course, the redirect is to the Tender
    # app.
    elif redirect_to in '//' and re.match(r'[^\?]*//', redirect_to):
        if redirect_to != tender_url:
            redirect_to = settings.LOGIN_REDIRECT_URL

    if request.user.is_authenticated():
        redirect_to = _add_sso(request, multipass, tender_url, redirect_to)
        return HttpResponseRedirect(redirect_to)

    if request.method == "POST":
        form = authentication_form(data=request.POST)
        if form.is_valid():
            auth_login(request, form.get_user())
            if request.session.test_cookie_worked():
                request.session.delete_test_cookie()
            redirect_to = _add_sso(request, multipass, tender_url, redirect_to)
            return HttpResponseRedirect(redirect_to)
    else:
        form = authentication_form(request)

    if multipass:
        login_url = reverse('account:multipass_login')
    else:
        login_url = reverse('account:login')

    request.session.set_test_cookie()
    return direct_to_template(request, template_name, {
        'form': form,
        'redirect_field_name': redirect_field_name,
        'redirect_to': redirect_to,
        'login_url': login_url})
dataset/ETHPy150Open bueda/django-comrade/comrade/users/views.py/login/swapped operands of `in`