Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Upgrade django-browserID to 0.10.1

Roland Geidercb83cc43ca9c
diff --git a/requirements.txt b/requirements.txt
index 25bef9abc..23d98693f 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -3,7 +3,7 @@
#
Django>=1.6,<1.7
-django-browserid==0.9
+django-browserid==0.10.1
django-recaptcha
reportlab
django_mobile
diff --git a/wger/core/static/js/browserid.js b/wger/core/static/js/browserid.js
deleted file mode 100644
index 0438ae3a3..000000000
--- a/wger/core/static/js/browserid.js
+++ /dev/null
@@ -1,87 +0,0 @@
-/* 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/. */
-
-(function($) {
- 'use strict';
-
- $(function() {
-
- // If there are problems initialising the browserID javascript
- // don't try to setup the watchers
- try{
- navigator.id.watch;
- }
- catch(error)
- {
- console.debug('navigator.id not available. Login with Persona not possible.');
- return;
- }
-
- // State? Ewwwwww.
- var loginRedirect = null; // Path to redirect to post-login.
- var logoutRedirect = null; // Path to redirect to post-logout.
-
- var $loginForm = $('#browserid-form'); // Form used to submit login.
- var $browseridInfo = $('#browserid-info'); // Useful info from backend.
-
- var requestArgs = $browseridInfo.data('requestArgs') || {};
- var loginFailed = location.search.indexOf('bid_login_failed=1') !== -1;
-
- // Call navigator.id.request whenever a login link is clicked.
- $(document).on('click', '.browserid-login', function(e) {
- e.preventDefault();
-
- loginRedirect = $(this).data('next');
- navigator.id.request(requestArgs);
- });
-
- // Call navigator.id.logout whenever a logout link is clicked.
- $(document).on('click', '.browserid-logout', function(e) {
- // Roland: Commented out
- //e.preventDefault();
-
- logoutRedirect = $(this).attr('href');
- navigator.id.logout();
- });
-
- navigator.id.watch({
- loggedInUser: $browseridInfo.data('userEmail') || null,
- onlogin: function(assertion) {
- // Avoid auto-login on failure.
- if (loginFailed) {
- loginFailed = false;
- return;
- }
-
- if (assertion) {
- $loginForm.find('input[name="next"]').val(loginRedirect);
- $loginForm.find('input[name="assertion"]').val(assertion);
- $loginForm.submit();
- }
- },
- onlogout: function() {
- // Follow the logout link's href once logout is complete.
-
- var currentLogoutUrl = logoutRedirect;
- if (currentLogoutUrl !== null) {
- logoutRedirect = null;
- window.location = currentLogoutUrl;
- } else {
- // Sometimes you can get caught in a loop where BrowserID
- // keeps trying to log you out as soon as watch is called,
- // and fails since the logout URL hasn't been set yet.
- // Here we just find the first logout button and use that
- // URL; if this breaks your site, you'll just need custom
- // JavaScript instead, sorry. :(
- currentLogoutUrl = $('.browserid-logout').attr('href');
- if (currentLogoutUrl) {
- // Roland: commented out
- // window.location = currentLogoutUrl;
- }
- }
- }
- });
- });
-})(jQuery);
-
diff --git a/wger/core/templates/mobile/template.html b/wger/core/templates/mobile/template.html
index 9de951e0c..943e21bd6 100644
--- a/wger/core/templates/mobile/template.html
+++ b/wger/core/templates/mobile/template.html
@@ -1,5 +1,5 @@
<!DOCTYPE html>
-{% load i18n %}{% load staticfiles %}{% load cache %}{% load browserid %}{% load compress %}{% load wger_extras %}
+{% load i18n %}{% load staticfiles %}{% load cache %}{% load compress %}{% load wger_extras %}
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
@@ -47,7 +47,6 @@
<script src="{% static 'js/exercises.js' %}"></script>
<script src="{% static 'js/weight.js' %}"></script>
<script src="{% static 'js/nutrition.js' %}"></script>
- <script src="{% static 'js/browserid.js' %}" type="text/javascript"></script>
{% endcompress %}
{% block header %}{% endblock %}
diff --git a/wger/core/templates/template.html b/wger/core/templates/template.html
index 6637ee758..ad8490f8f 100644
--- a/wger/core/templates/template.html
+++ b/wger/core/templates/template.html
@@ -1,6 +1,5 @@
<!DOCTYPE html>
{% load i18n %}
-{% load browserid %}
{% load staticfiles %}
{% load wger_extras %}
{% load compress %}
@@ -44,7 +43,6 @@
<script src="{% static 'js/jquery-ui.js' %}" type="text/javascript"></script>
<script src="{% static 'js/d3.js' %}" type="text/javascript"></script>
<script src="{% static 'js/workout-manager.js' %}" type="text/javascript"></script>
- <script src="{% static 'js/browserid.js' %}" type="text/javascript"></script>
<script src="{% static 'js/ubuntu-unity.js' %}" type="text/javascript"></script>
<script src="{% static 'js/bootstrap.min.js' %}" type="text/javascript"></script>
<script src="{% static 'js/bootstrap-datepicker/bootstrap-datepicker.min.js' %}" type="text/javascript"></script>
@@ -52,7 +50,7 @@
<script src="{% static 'js/weight.js' %}" type="text/javascript"></script>
<script src="{% static 'js/nutrition.js' %}" type="text/javascript"></script>
{% endcompress %}
-
+s
{% if language.short_name != 'en' %}
<script src="{% static datepicker_i18n_path %}" type="text/javascript"></script>
{% endif %}
@@ -88,7 +86,6 @@
<title>{% block title %}{% endblock %}</title>
</head>
<body>
-{% browserid_info %}
<header>
<div class="container">
<div class="row">
@@ -185,7 +182,5 @@
</div>
</div>
</footer>
-
-<script src="https://login.persona.org/include.js" type="text/javascript"></script>
</body>
</html>
diff --git a/wger/core/templates/user/login.html b/wger/core/templates/user/login.html
index 35c3c64cc..ff7395bac 100644
--- a/wger/core/templates/user/login.html
+++ b/wger/core/templates/user/login.html
@@ -8,7 +8,12 @@
{% block header %}
-{% browserid_css %}
+<link rel="stylesheet" href="{% static 'browserid/persona-buttons.css' %}">
+<script src="https://login.persona.org/include.js"></script>
+<script src="{% static 'browserid/api.js' %}"></script>
+<script src="{% static 'browserid/browserid.js' %}"></script>
+
+{% browserid_info %}
{% endblock %}
{% block content %}
diff --git a/wger/main.py b/wger/main.py
index 7e983db5c..29e985fde 100755
--- a/wger/main.py
+++ b/wger/main.py
@@ -68,6 +68,7 @@ RECAPTCHA_PRIVATE_KEY = '%(recaptcha_private_key)s'
# The site's URL (e.g. http://www.my-local-gym.com or http://localhost:8000)
# This is needed for Mozilla's BrowserID to work
SITE_URL = '%(siteurl)s'
+BROWSERID_AUDIENCES = [SITE_URL]
# This might be a good idea if you setup memcached
#SESSION_ENGINE = "django.contrib.sessions.backends.cache"
diff --git a/wger/settings_global.py b/wger/settings_global.py
index 83cb7f315..695560e7d 100644
--- a/wger/settings_global.py
+++ b/wger/settings_global.py
@@ -62,7 +62,6 @@ TEMPLATE_CONTEXT_PROCESSORS = (
'wger.utils.context_processor.processor',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
- 'django_browserid.context_processors.browserid',
# Django mobile
'django_mobile.context_processors.flavour',
diff --git a/wger/urls.py b/wger/urls.py
index 0777f90d3..25dcf1d2b 100644
--- a/wger/urls.py
+++ b/wger/urls.py
@@ -155,6 +155,9 @@ urlpatterns = urlpatterns + patterns('',
url(r'^manifest\.webapp$', WebappManifestView.as_view(template_name="manifest.webapp")),
url(r'^amazon-manifest\.webapp$', WebappManifestView.as_view(template_name="amazon-manifest.webapp")),
+ # persona (browserID) login
+ url(r'^browserid/', include('django_browserid.urls')),
+
# API
url(r'^api/', include(v1_api.urls)),
url(r'^api/v2/exercise/search/$',