Ignore:
Timestamp:
21 Aug 2013, 21:08:11 (11 years ago)
Author:
Henrik Bettermann
Message:

Be more verbose if credentials checking fails.

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

Legend:

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

    r10518 r10522  
    193193            # Usernames in Moodle must not contain uppercase
    194194            # letters even if extendedusernamechars is set True.
     195            # Usernames in Moodle are case insensitive.
     196            # In other words, Moodle changes usernames from
     197            # uppercase to lowercase when you login.
    195198            result = moodle.core_user_create_users([
    196199                {'username':username.lower(),
     
    237240            if principal is None:
    238241                principal = proxy.check_student_credentials(username, password)
    239             if principal is not None:
    240                 if principal['type'] == 'student':
    241                     userdata = proxy.get_student_moodle_data(username)
    242                     return self._create_user(username, userdata, moodle)
    243                 if principal['type'] == 'applicant':
    244                     userdata = proxy.get_applicant_moodle_data(username)
    245                     return self._create_user(username, userdata, moodle)
    246         return (False, 'Invalid username or password or user not eligible.')
     242            if principal is None:
     243                return (False, 'Invalid username or password')
     244            if principal['type'] == 'student':
     245                userdata = proxy.get_student_moodle_data(username)
     246                return self._create_user(username, userdata, moodle)
     247            if principal['type'] == 'applicant':
     248                userdata = proxy.get_applicant_moodle_data(username)
     249                return self._create_user(username, userdata, moodle)
     250            return (False, 'User not eligible')
     251        return (False, 'Invalid username or password')
     252
  • main/waeup.cas/trunk/waeup/cas/tests/test_authenticators.py

    r10518 r10522  
    190190        if username == 'fault5' and password == 'biz':
    191191            return {'type': 'applicant'}
     192        if username == 'fault6' and password == 'biz':
     193            return {'type': 'boss'}
    192194        return None
    193195
     
    351353        assert result1a == (True, '')
    352354        result2s = auth.check_credentials('SCHOOL1-foo', 'bar')
    353         assert result2s == (
    354             False, 'Invalid username or password or user not eligible.')
     355        assert result2s == (False, 'Invalid username or password')
    355356        result3s = auth.check_credentials('SCHOOL2-bar', 'baz')
    356         assert result3s == (
    357             False, 'Invalid username or password or user not eligible.')
     357        assert result3s == (False, 'Invalid username or password')
     358        result8 = auth.check_credentials('SCHOOL1-fault6', 'biz')
     359        assert result8 == (False, 'User not eligible')
    358360
    359361        # exceptions are raised in the follwoing cases
Note: See TracChangeset for help on using the changeset viewer.