1. Domen Kožar
  2. repoze.who.plugins.recaptcha

Commits

iElectric  committed 7f5f0a1

validation should be done once, ignore identities other than the first one.

  • Participants
  • Parent commits 5fc3ac1
  • Branches default

Comments (0)

Files changed (3)

File CHANGES.txt

View file
 CHANGELOG:
 ===========
 
-0.1 - 21.09.2008 
+0.3 - xxx
 ------------------
-* Inital release
+* Change: removed uneeded imports
+* Fix: validation should be done once, ignore identities other than the first one.
+* Fix: more accurate tests
+
 
 0.2 - 23.09.2008
 ------------------
 * Change: ident fixes
 * Change: use repoze.who.logger
 
+0.1 - 21.09.2008 
+------------------
+* Inital release
+
+

File repoze/who/plugins/captcha.py

View file
         self.handler = form_handler
 
     def authenticate(self, environ, identity):
+        log = environ['repoze.who.logger']
 
-        log = environ['repoze.who.logger']
+        if environ.get('__RECAPTCHA_DONE'):
+            log.debug('recaptcha validation has already been done.')
+            return None
+        else:
+            environ['__RECAPTCHA_DONE'] = True
 
         # check if validation is needed
         if self.handler:

File repoze/who/plugins/test_captcha.py

View file
 PRIVATE_KEY = 'whocares'
 
 class DummyLogger(object):
+    messages = []
     def debug(self, msg):
-        return msg
+        self.messages.append(msg)
 
 class TestFormPlugin(Base):
     def _getTargetClass(self):
         self.assert_(isinstance(environ['repoze.who.error'], basestring))
         self.assertEqual(app.code, 401)
 
+    def test_two_identifiers(self):
+
+        plugin = self._makeOne(PRIVATE_KEY)
+        environ = self._makeFormEnviron()
+        environ['repoze.who.logger'].messages = []
+
+        plugin.authenticate(environ, environ['repoze.who.plugins']['cookie'])
+        self.assert_('recaptcha validation has already been done.' not in environ['repoze.who.logger'].messages)
+
+        plugin.authenticate(environ, environ['repoze.who.plugins']['cookie'])
+        self.assert_('recaptcha validation has already been done.' in environ['repoze.who.logger'].messages)
+