Mercurial > moin > 1.9
changeset 6057:e1e9c0f9d7dd
textcha failures: log reason
author | Thomas Waldmann <tw AT waldmann-edv DOT de> |
---|---|
date | Thu, 04 Sep 2014 14:12:27 +0200 |
parents | fde5fea5986a |
children | 5fb9d0f4af89 4dbfb3fec02a |
files | MoinMoin/security/textcha.py |
diffstat | 1 files changed, 9 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/MoinMoin/security/textcha.py Thu Aug 21 16:51:58 2014 +0200 +++ b/MoinMoin/security/textcha.py Thu Sep 04 14:12:27 2014 +0200 @@ -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: