/*!
 * wwwhisper - web access control.
 */
(function () {
  'use strict';
  var stub = new wwwhisper.Stub();

  /**
   * Sends an assertion from a BrowserID sign-in window to the
   * authentication back-end. Reloads the page if login succeeded.
   */
  function verifyEmail(email) {
    stub.ajax('POST', '/wwwhisper/auth/api/send-token/',
              {'email' : email,
               'path': location.pathname
              },
              function() {
                alert('verifivation email was sent');
              },
              function(errorMessage, errorStatus) {
                if (errorStatus === 403) {
                  // Login failed because the user is unknown.
                  $('#login-required').addClass('hide');
                  $('#nothing-shared').removeClass('hide');
                } else {
                  // Other error.
                  $('body').html(errorMessage);
                }
              });
  }

  /**
   * Goes to the logout page if the user is already authenticated.
   */
  function gotoLogoutIfAuthenticated() {
    // Whoami succeeds only for authenticated users.
    stub.ajax('GET', '/wwwhisper/auth/api/whoami/', null,
              function() {
                window.location = '/wwwhisper/auth/logout';
              },
              function() {
                // Logget out (errorStatus 401) or some other error.
                // If error was caused by disabled cookies (CSRF token
                // missing), Persona dialog will inform the user how
                // to enable cookies.
              });
  }

  $('#login-required').removeClass('hide');

  // Register a callback to process a BrowserID assertion.
  $('#verify-button').click(function() {
    verifyEmail($('#email-input').val());
  });

  gotoLogoutIfAuthenticated();

}());

@@ -260,29 +260,50 @@
 ion 
-verifyEmail(email
+login(assertion) %7B%0A    if (assertion
 ) %7B%0A
+  
     
@@ -345,17 +345,12 @@
 api/
-send-toke
+logi
 n/',
@@ -368,84 +368,52 @@
     
-%7B'email' : email,%0A               'path': location.pathname%0A             
+  %7B 'assertion' : assertion.toString()
  %7D,%0A
+  
     
@@ -455,46 +455,42 @@
     
-alert('verifivation email was sent'
+  window.location.reload(true
 );%0A
+  
     
@@ -508,32 +508,34 @@
 ,%0A              
+ 
+ 
 function(errorMe
@@ -568,24 +568,26 @@
             
+  
 if (errorSta
@@ -615,24 +615,26 @@
             
+ 
+ 
 // Login fai
@@ -666,16 +666,18 @@
 nknown.%0A
+  
         
@@ -739,24 +739,26 @@
             
+  
 $('#nothing-
@@ -803,16 +803,18 @@
         
+  
 %7D else %7B
@@ -814,16 +814,18 @@
  else %7B%0A
+  
         
@@ -868,16 +868,18 @@
         
+  
 $('body'
@@ -916,18 +916,22 @@
         
-%7D%0A
+  %7D%0A  
         
@@ -936,24 +936,30 @@
         %7D);%0A
+    %7D%0A
   %7D%0A%0A  /**%0A 
@@ -1626,16 +1626,51 @@
 'hide');
+%0A  $('#login').removeClass('hide');
 %0A%0A  // R
@@ -1732,20 +1732,12 @@
 $('#
-verify-butto
+logi
 n').
@@ -1763,44 +1763,49 @@
     
-verifyEmail($('#email-input').val())
+navigator.id.get(login);%0A    return false
 ;%0A  

Revert accidentally committed changes to login JavaScript logic.