This repository has been archived by the owner on Oct 28, 2020. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #910 from akatsoulas/upgrade-browserid
Upgrade browserid to version 0.11
- Loading branch information
Showing
76 changed files
with
15,631 additions
and
9,496 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.