def logout(request, login_url=None, **kwargs):
    """Logs out the user if he is logged in. Then redirects to the log-in page.

    :param login_url:
        Once logged out, defines the URL where to redirect after login

    :param kwargs:
        see django.contrib.auth.views.logout_then_login extra parameters.

    """
    msg = 'Logging out user "%(username)s".' % \
        {'username': request.user.username}
    LOG.info(msg)

    """ Securely logs a user out. """
    if (utils.is_websso_enabled and utils.is_websso_default_redirect() and
            utils.get_websso_default_redirect_logout()):
        auth_user.unset_session_user_variables(request)
        return django_http.HttpResponseRedirect(
            utils.get_websso_default_redirect_logout())
    else:
        return django_auth_views.logout_then_login(request,
                                                   login_url=login_url,
                                                   **kwargs)
Logs out the user if he is logged in. Then redirects to the log-in page.

    :param login_url:
        Once logged out, defines the URL where to redirect after login

    :param kwargs:
        see django.contrib.auth.views.logout_then_login extra parameters.