diff --git a/rhodecode/lib/helpers.py b/rhodecode/lib/helpers.py --- a/rhodecode/lib/helpers.py +++ b/rhodecode/lib/helpers.py @@ -1906,13 +1906,18 @@ def secure_form(url, method="POST", mult """ from webhelpers.pylonslib.secure_form import insecure_form form = insecure_form(url, method, multipart, **attrs) - token = csrf_input() + + session = None + # TODO(marcink): after pyramid migration require request variable ALWAYS + if 'request' in attrs: + session = attrs['request'].session + + token = literal( + ''.format( + csrf_token_key, csrf_token_key, get_csrf_token(session))) + return literal("%s\n%s" % (form, token)) -def csrf_input(): - return literal( - ''.format( - csrf_token_key, csrf_token_key, get_csrf_token())) def dropdownmenu(name, selected, options, enable_filter=False, **attrs): select_html = select(name, selected, options, **attrs) diff --git a/rhodecode/model/forms.py b/rhodecode/model/forms.py --- a/rhodecode/model/forms.py +++ b/rhodecode/model/forms.py @@ -49,6 +49,7 @@ from pkg_resources import resource_filen from formencode import All, Pipe from pylons.i18n.translation import _ +from pyramid.threadlocal import get_current_request from rhodecode import BACKENDS from rhodecode.lib import helpers @@ -66,6 +67,7 @@ class RhodecodeFormZPTRendererFactory(de """ Subclass of ZPTRendererFactory to add rhodecode context variables """ def __call__(self, template_name, **kw): kw['h'] = helpers + kw['request'] = get_current_request() return self.load(template_name)(**kw) diff --git a/rhodecode/templates/admin/auth/auth_settings.mako b/rhodecode/templates/admin/auth/auth_settings.mako --- a/rhodecode/templates/admin/auth/auth_settings.mako +++ b/rhodecode/templates/admin/auth/auth_settings.mako @@ -38,7 +38,7 @@