Changeset 10396


Ignore:
Timestamp:
4 Jul 2013, 10:45:39 (11 years ago)
Author:
uli
Message:

Let authtenticators give back a reason if login fails.

Location:
main/waeup.cas/trunk/waeup/cas
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.cas/trunk/waeup/cas/authenticators.py

    r10394 r10396  
    9797
    9898    def check_credentials(self, username='', password=''):
    99         """If username is ``'bird'`` and password ``'bebop'`` return
    100         ``True``, else ``False``.
     99        """If username is ``'bird'`` and password ``'bebop'`` check
     100        will succeed.
     101
     102        Returns a tuple ``(<STATUS>, <REASON>)`` with ``<STATUS>``
     103        being a boolean and ``<REASON>`` being a string giving the
     104        reason why login failed (if so) or an empty string.
    101105        """
    102         return username == 'bird' and password == 'bebop'
     106        reason = ''
     107        result = username == 'bird' and password == 'bebop'
     108        if not result:
     109            reason = 'Invalid username or password.'
     110        return result, reason
  • main/waeup.cas/trunk/waeup/cas/tests/test_authenticators.py

    r10394 r10396  
    5151        auth = DummyAuthenticator()
    5252        result1 = auth.check_credentials('bird', 'bebop')
    53         assert result1 is True
     53        assert result1 == (True, '')
    5454        result2 = auth.check_credentials('foo', 'bar')
    55         assert result2 is False
     55        assert result2 == (False, 'Invalid username or password.')
Note: See TracChangeset for help on using the changeset viewer.