django-cas
django-cas copied to clipboard
Strip usernames when creating them
I ran into a situation today where duplicate user accounts were being created. After some digging around I noticed that if a user typed in a leading or trailing space while typing their username then it would treat these accounts as unique and create a new record in auth_user
. This can lead to confusing results for the end user as anything associated with an account they might of had previously looks to them as if it disappeared.
Would you be willing to accept a patch for backends.py
[1] with something to the effect of:
username = _verify(ticket, service)
if not username:
return None
username = username.strip()
[1] https://github.com/kstateome/django-cas/blob/develop/cas/backends.py#L231
i think it would be better to strip the username in _verify. in function '_verify_cas1', strip has been done.
in function '_internal_verify_cas', change username = tree[0][0].text to username = tree[0][0].text.strip()
fix at #59