Improve error message wording (#564)
Improve error message wording if no csf cookie could be detected. Also, make the error text translatable.
This commit is contained in:
parent
56cf9f5ff1
commit
947c08ae43
@ -22,6 +22,7 @@ from wtforms import Form, HiddenField, validators
|
|||||||
|
|
||||||
from mediagoblin import mg_globals
|
from mediagoblin import mg_globals
|
||||||
from mediagoblin.meddleware import BaseMeddleware
|
from mediagoblin.meddleware import BaseMeddleware
|
||||||
|
from mediagoblin.tools.translate import lazy_pass_to_ugettext as _
|
||||||
|
|
||||||
_log = logging.getLogger(__name__)
|
_log = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -127,10 +128,13 @@ class CsrfMeddleware(BaseMeddleware):
|
|||||||
None)
|
None)
|
||||||
|
|
||||||
if cookie_token is None:
|
if cookie_token is None:
|
||||||
# the CSRF cookie must be present in the request
|
# the CSRF cookie must be present in the request, if not a
|
||||||
errstr = 'CSRF cookie not present'
|
# cookie blocker might be in action (in the best case)
|
||||||
_log.error(errstr)
|
_log.error('CSRF cookie not present')
|
||||||
raise Forbidden(errstr)
|
raise Forbidden(_('CSRF cookie not present. This is most likely '
|
||||||
|
'the result of a cookie blocker or somesuch.<br/>'
|
||||||
|
'Make sure to permit the settings of cookies for '
|
||||||
|
'this domain.'))
|
||||||
|
|
||||||
# get the form token and confirm it matches
|
# get the form token and confirm it matches
|
||||||
form = CsrfForm(request.form)
|
form = CsrfForm(request.form)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user