65da9302e4feddfbbd5ad7f55072fe386373690f kate Mon Apr 14 16:47:55 2014 -0700 Navigation bar dynamics for EDW diff --git src/hg/js/edwPersona.js src/hg/js/edwPersona.js index 9ad4e7b..3dbe144 100644 --- src/hg/js/edwPersona.js +++ src/hg/js/edwPersona.js @@ -1,29 +1,36 @@ /* edwPersona.js - Hooks up signin and signout buttons to Persona authentication. */ $(function () { var email = $.cookie("email"); var signInLink = document.getElementById('signin'); if (signInLink) { signInLink.onclick = function() { navigator.id.request(); }; } var signOutLink = document.getElementById('signout'); if (signOutLink) { signOutLink.onclick = function() { navigator.id.logout(); }; } + // update navigation bar to show email of logged in user + if (email != null) { + $('#edw-user').text(email); + } else { + $('#signout').hide(); + } + navigator.id.watch({ loggedInUser: email, onlogin: function(assertion) { // A user has logged in! Here you need to: // 1. Send the assertion to your backend for verification and to create a session. // 2. Update your UI. $.ajax({ /* <-- This example uses jQuery, but you can use whatever you'd like */ type: 'POST', url: 'edwWebAuthLogin', // This is a URL on your website. data: {assertion: assertion}, success: function(res, status, xhr) { window.location.reload(); }, error: function(xhr, status, err) { navigator.id.logout(); alert("Login failure: " + err); }