This repository has been archived by the owner on Jan 8, 2019. 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.
- Loading branch information
Showing
86 changed files
with
15,120 additions
and
609 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
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,15 +1,67 @@ | |||
/* This Source Code Form is subject to the terms of the Mozilla Public | /* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | * License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
$(document).ready(function() { |
|
||
$('#browserid').bind('click', function(e) { | (function($) { | ||
e.preventDefault(); | 'use strict'; | ||
navigator.id.getVerifiedEmail(function(assertion) { |
|
||
if (assertion) { | $(function() { | ||
var $e = $('#id_assertion'); | // State? Ewwwwww. | ||
$e.val(assertion.toString()); | var logoutButton = null; | ||
$e.parent().submit(); | var requestOptions = [ | ||
'siteName', | |||
'siteLogo', | |||
'oncancel', | |||
'privacyPolicy', | |||
'returnTo', | |||
'termsOfService' | |||
]; | |||
|
|||
$(document).delegate('.browserid-login, #browserid', 'click', function(e) { | |||
e.preventDefault(); | |||
|
|||
// Arguments to navigator.id.request can be specified by data-attributes | |||
// on the BrowserID link: <a href="#" data-site-name="Site Name"> | |||
var options = {}; | |||
var $link = $(e.target); | |||
for (var k = 0; k < requestOptions.length; k++) { | |||
var name = requestOptions[k]; | |||
var value = $link.data(name); | |||
if (value !== undefined) { | |||
options[name] = value; | |||
} | |||
} | |||
|
|||
navigator.id.request(options); // Triggers BrowserID login dialog. | |||
}); | |||
|
|||
$('.browserid-logout').bind('click', function(e) { | |||
e.preventDefault(); | |||
logoutButton = e.target; | |||
navigator.id.logout(); // Clears User Agent BrowserID state. | |||
}); | |||
|
|||
navigator.id.watch({ | |||
onlogin: function(assertion) { | |||
// Don't bother if login just failed. | |||
if (location.search.indexOf('bid_login_failed=1') !== -1) { | |||
navigator.id.logout(); | |||
} else if (assertion) { | |||
var $e = $('#id_assertion'); | |||
$e.val(assertion.toString()); | |||
$e.parent().submit(); | |||
} | |||
}, | |||
|
|||
onlogout: function() { | |||
var currentButton = logoutButton; | |||
if (currentButton !== null) { | |||
logoutButton = null; | |||
if (currentButton.href) { | |||
window.location = currentButton.href; | |||
} | |||
} | |||
} | } | ||
}); | }); | ||
}); | }); | ||
}); | })(jQuery); |
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,23 @@ | |||
""" | |||
This Source Code Form is subject to the terms of the Mozilla Public | |||
License, v. 2.0. If a copy of the MPL was not distributed with this | |||
file, You can obtain one at http://mozilla.org/MPL/2.0/. | |||
""" | |||
from django.db import models | |||
|
|||
try: | |||
from django.contrib.auth.models import AbstractBaseUser | |||
except ImportError: | |||
AbstractBaseUser = object | |||
|
|||
|
|||
class CustomUser(AbstractBaseUser): | |||
USERNAME_FIELD = 'email' | |||
|
|||
email = models.EmailField(unique=True, db_index=True) | |||
|
|||
def get_full_name(self): | |||
return self.email | |||
|
|||
def get_short_name(self): | |||
return self.email |
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.