Mercurial > moin > 1.9
changeset 6068:4dbfb3fec02a
merge upstream
author | 'Karl O. Pinc' <kop@meme.com> |
---|---|
date | Thu, 04 Sep 2014 14:48:36 -0500 |
parents | 082b1a458d55 (current diff) e1e9c0f9d7dd (diff) |
children | 0e1b5fdca6bc |
files | |
diffstat | 1 files changed, 9 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/MoinMoin/security/textcha.py Thu Sep 04 14:18:56 2014 -0500 +++ b/MoinMoin/security/textcha.py Thu Sep 04 14:48:36 2014 -0500 @@ -130,26 +130,34 @@ def check_answer(self, given_answer, timestamp, signature): """ check if the given answer to the question is correct and within the correct timeframe""" if self.is_enabled(): + reason = 'ok' if self.answer_re is not None: success = self.answer_re.match(given_answer.strip()) is not None + if not success: + reason = 'answer_re did not match' else: # someone trying to cheat!? success = False + reason = 'answer_re is None' if not timestamp or timestamp + self.expiry_time < time(): success = False + reason = 'textcha expired' try: if not safe_str_equal(self._compute_signature(self.question, timestamp), signature): success = False + reason = 'signature mismatch' except TypeError: success = False + reason = 'TypeError during signature check' success_status = success and u"success" or u"failure" - logging.info(u"TextCha: %s (u='%s', a='%s', re='%s', q='%s')" % ( + logging.info(u"TextCha: %s (u='%s', a='%s', re='%s', q='%s', rsn='%s')" % ( success_status, self.user_info, given_answer, self.answer_regex, self.question, + reason, )) return success else: