[damned-lies] Allow for non-ascii chars in usernames during registration
- From: Claude Paroz <claudep src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [damned-lies] Allow for non-ascii chars in usernames during registration
- Date: Thu, 11 Apr 2013 08:53:08 +0000 (UTC)
commit b67fb0d12a3962d7ab817d3758a0c6cecd2b4717
Author: Claude Paroz <claude 2xlibre net>
Date: Thu Apr 11 10:52:47 2013 +0200
Allow for non-ascii chars in usernames during registration
people/forms.py | 3 ++-
people/tests/__init__.py | 2 +-
2 files changed, 3 insertions(+), 2 deletions(-)
---
diff --git a/people/forms.py b/people/forms.py
index 21fb7ce..0ffb0ea 100644
--- a/people/forms.py
+++ b/people/forms.py
@@ -5,6 +5,7 @@ from django import forms
from django.conf import settings
from django.contrib.sites.models import Site
from django.core.urlresolvers import reverse
+from django.utils.encoding import force_bytes
from django.utils.translation import ugettext_lazy, ugettext as _
from teams.models import Team
@@ -70,7 +71,7 @@ class RegistrationForm(forms.Form):
from django_openid_auth.models import UserOpenID
user_oid = UserOpenID.objects.create(user=new_user, claimed_id=openid)
salt = hashlib.sha1(str(random.random())).hexdigest()[:5]
- activation_key = hashlib.sha1(salt+username).hexdigest()
+ activation_key = hashlib.sha1(salt+force_bytes(username)).hexdigest()
new_user.activation_key = activation_key
new_user.is_active = False
new_user.save()
diff --git a/people/tests/__init__.py b/people/tests/__init__.py
index 55f8fd2..f36efff 100644
--- a/people/tests/__init__.py
+++ b/people/tests/__init__.py
@@ -40,7 +40,7 @@ class PeopleTestCase(TestCase):
def test_register(self):
response = self.client.post(reverse('register'),
- {'username': u'test01', 'password1': u'1234567',
+ {'username': u'tèst01', 'password1': u'1234567',
'password2': u'1234567', 'email': u'test01 example org'})
self.assertRedirects(response, reverse('register_success'))
self.assertEqual(Person.objects.filter(username=u'test01').count(), 1)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]