Commits

Dan Callahan  committed 90842ac

Switch to demo of persona.js

  • Participants
  • Parent commits bd8ad8b

Comments (0)

Files changed (1)

File templates/index.html

     <p>You can <a href="#" id="signin">Sign In</a></p>
     {% endif %}
 
-    <script type="text/javascript" src="/static/jquery-1.7.2.min.js"></script>
-    <script type="text/javascript" src="http://login.persona.org/include.js"></script>
+    <script type="text/javascript" src="https://raw.github.com/lloyd/persona.js/master/persona.js"></script>
     <script type="text/javascript">
-      /* What should we do when a user is logged in or out? */
-
-      // Who do we think is logged in right now?
-      {% if session.email %}
-      var currentUser = '{{ session.email }}';
-      {% else %}
-      var currentUser = null;
-      {% endif %}
-
-      navigator.id.watch({
-        // Who do we think is logged in?
-        loggedInEmail: currentUser,
-
-        // On a login event, we should get an "assertion" from the user.
-        // Send it to our server's backend for verification.
-        onlogin: function(assertion) {
-          console.log('Got assertion: ' + assertion);
-          $.ajax({
-            type: 'POST',
-            url: '/login', // This is a URL on our website.
-            data: {assertion: assertion},
-            success: function() { window.location.reload(); },
-          });
-          return false;
-        },
-
-        // On a logout event, we should clear the user's session.
-        // Let's do that by POSTing to a logout page on our server.
-        onlogout: function() {
-          navigator.id.logout();
-          $.ajax({
-            type: 'POST',
-            url: '/logout', // This is a URL on our website.
-            success: function() { window.location.reload(); }
-          });
-          return false;
-        }
+      Persona.setup({
+        login: { target: '/login', selector: '#signin' },
+        logout: { target: '/logout', selector: '#signout' },
       });
-
-
-
-      /* Hook up sign in / sign out links */
-
-      // Execute navigator.id.request(); when the user clicks "Sign In"
-      var signinLink = document.getElementById('signin');
-      if (signinLink) {
-        signinLink.onclick = function() { navigator.id.request(); };
-      };
-
-      // Execute navigator.id.logout(); when the user clicks "Sign Out"
-      var signoutLink = document.getElementById('signout');
-      if (signoutLink) {
-        signoutLink.onclick = function() { navigator.id.logout(); };
-      };
     </script>
   </body>
 </html>