Skip to content
This repository has been archived by the owner on Oct 28, 2020. It is now read-only.

Commit

Permalink
Merge pull request #910 from akatsoulas/upgrade-browserid
Browse files Browse the repository at this point in the history
Upgrade browserid to version 0.11
  • Loading branch information
akatsoulas committed Feb 3, 2015
2 parents 76f7293 + 7f1746d commit 45966fa
Show file tree
Hide file tree
Showing 76 changed files with 15,631 additions and 9,496 deletions.
3 changes: 0 additions & 3 deletions .gitmodules
Expand Up @@ -34,9 +34,6 @@
[submodule "vendor-local/src/django-database-email-backend"]
path = vendor-local/src/django-database-email-backend
url = https://github.com/stefanfoulis/django-database-email-backend.git
[submodule "vendor-local/src/django-browserid"]
path = vendor-local/src/django-browserid
url = git://github.com/mozilla/django-browserid.git
[submodule "vendor-local/src/django"]
path = vendor-local/src/django
url = git://github.com/django/django.git
2 changes: 0 additions & 2 deletions .travis.yml
Expand Up @@ -7,9 +7,7 @@ before_install:
- mysql -e 'create database remo character set utf8;'
- git submodule update --init --recursive
install:
- pip install -r requirements/compiled.txt
- pip install -r requirements/dev.txt
- pip install coverage
script:
- python manage.py test --with-coverage --cover-erase --cover-package=remo
after_success:
Expand Down
39 changes: 39 additions & 0 deletions remo/base/backend.py
@@ -0,0 +1,39 @@
from django.conf import settings
from django.contrib.auth.models import Group, User

from django_browserid.auth import BrowserIDBackend, default_username_algo

from remo.base.mozillians import BadStatusCodeError, is_vouched


USERNAME_ALGO = getattr(settings, 'BROWSERID_USERNAME_ALGO',
default_username_algo)


class RemoBrowserIDBackend(BrowserIDBackend):

def create_user(self, email):
try:
data = is_vouched(email)
except BadStatusCodeError:
data = None

# Add vouched mozillians to our db please.
if data and data['is_vouched']:
user = User.objects.create_user(username=USERNAME_ALGO(email),
email=email)
# Due to privacy settings, this might be missing
if 'full_name' not in data:
data['full_name'] = 'Anonymous Mozillian'
else:
user.userprofile.mozillian_username = data['username']
user.userprofile.save()

first_name, last_name = (data['full_name'].split(' ', 1)
if ' ' in data['full_name']
else ('', data['full_name']))
user.first_name = first_name
user.last_name = last_name
user.save()
user.groups.add(Group.objects.get(name='Mozillians'))
return user
2 changes: 1 addition & 1 deletion remo/base/middleware.py
Expand Up @@ -20,7 +20,7 @@ def process_request(self, request):
request.user.userprofile.registration_complete and not
request.user.groups.filter(name='Mozillians').exists()):
allow_urls = [
reverse('browserid_logout'),
reverse('browserid.logout'),
reverse('profiles_edit',
kwargs={'display_name':
request.user.userprofile.display_name})]
Expand Down

0 comments on commit 45966fa

Please sign in to comment.