Commit 5e689ea2 authored by Abhilash Raj's avatar Abhilash Raj

replace django-social-auth with django-browserid

parent 1e912847
......@@ -40,6 +40,6 @@ setup(
package_dir={'': 'src'},
include_package_data=True,
install_requires=['django>=1.5',
'django-social-auth>=0.7.8',
'django-browserid',
'mailmanclient']
)
......@@ -2,8 +2,10 @@
{% load url from future %}
{% load i18n %}
{% load staticfiles %}
{% load browserid %}
{% block main %}
{% browserid_info %}
<div id="container">
<p><strong>{% trans "Login with username and password or with Mozilla Persona" %}</strong></p>
......@@ -17,15 +19,18 @@
</form>
</div>
<div class="mm_login_b">
<form method="post" action="{% url 'socialauth_complete' "browserid" %}"> {% csrf_token %}
<input type="hidden" name="assertion" value="" />
<a rel="nofollow" id="browserid" href="#"><img src="{% static 'postorius/img/sign_in_blue.png' %}" alt="{% trans 'Login using BrowserID' %}" /></a>
</form>
<p>{% trans "Mozilla Persona is an easy way to sign into multiple websites, while still controlling your personal data. For more information <a href='http://www.mozilla.org/en-US/persona'>see the Mozilla website</a>" %}.</p>
<noscript><p class="text-error">{% trans "Mozilla Persona requires the use of
JavaScript." %}</p></noscript>
<a rel="nofollow" id="browserid" href="#">
<img src="{% static 'postorius/img/sign_in_blue.png' %}"
alt="{% trans 'Login using BrowserID' %}" />
</a>
<p>{% trans "Mozilla Persona is an easy way to sign into multiple websites, while still controlling your personal data. For more information <a href='http://www.mozilla.org/en-US/persona'>see the Mozilla website</a>" %}.
</p>
<noscript>
<p class="text-error">
{% trans "Mozilla Persona requires the use of JavaScript." %}
</p>
</noscript>
</div>
<div style="clear:both">
</div>
......@@ -35,24 +40,19 @@ JavaScript." %}</p></noscript>
{% block additionaljs %}
<!-- Include BrowserID JavaScript -->
<script src="https://login.persona.org/include.js" type="text/javascript"></script>
<script src="{% static 'browserid/api.js' %}" type="text/javascript"></script>
<script src="{% static 'browserid/browserid.js' %}" type="text/javascript"></script>
<!-- Setup click handler that receives BrowserID assertion code and sends
POST data -->
<script type="text/javascript">
$(function () {
$('#browserid').click(function (e) {
e.preventDefault();
var self = $(this);
navigator.id.get(function (assertion) {
if (assertion) {
self.parent('form')
.find('input[type=hidden]')
.attr('value', assertion)
.end()
.submit();
}
});
$('#browserid').click(function (e) {
django_browserid.login().then(function(verifyResult) {
window.location = verifyResult.redirect;
}, function(jqXHR) {
window.alert('There was an error logging in, please try again.');
});
});
});
</script>
<!-- end browserid stuff -->
......
......@@ -89,8 +89,7 @@ TEMPLATE_LOADERS = (
AUTHENTICATION_BACKENDS = (
'django.contrib.auth.backends.ModelBackend',
'social_auth.backends.OpenIDBackend',
'social_auth.backends.browserid.BrowserIDBackend',
'django_browserid.auth.BrowserIDBackend',
)
TEMPLATE_CONTEXT_PROCESSORS = (
......@@ -103,9 +102,6 @@ TEMPLATE_CONTEXT_PROCESSORS = (
"django.core.context_processors.csrf",
"django.contrib.messages.context_processors.messages",
"postorius.context_processors.postorius",
'social_auth.context_processors.social_auth_by_name_backends',
'social_auth.context_processors.social_auth_backends',
'social_auth.context_processors.social_auth_by_type_backends',
)
MIDDLEWARE_CLASSES = (
......@@ -141,7 +137,7 @@ INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.staticfiles',
'postorius',
'social_auth',
'django_browserid',
# These are only used for development
# 'debug_toolbar',
)
......@@ -149,6 +145,10 @@ LOGIN_URL = '/postorius/accounts/login/'
LOGIN_REDIRECT_URL = '/postorius/'
LOGIN_ERROR_URL = '/postorius/accounts/login/'
def username(email):
return email.rsplit('@', 1)[0]
BROWSERID_USERNAME_ALGO = username
TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'
NOSE_ARGS = [
'--with-coverage',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment