<!DOCTYPE html>

<html>
  <head>
    <meta charset="utf-8" />
    <title></title>
  </head>

  <body>
    <script src="scripts/lib/jquery.js" type="text/javascript"></script>
    <script type="text/javascript">
      var host = 'https://login.zooniverse.org/';
      if (!!~location.host.indexOf('localhost')) host = 'http://localhost:3000';

      var commandMap = {
        'authenticate': '/login',
        'log-out': '/logout'
      };

      $(window).on('message', function(e) {
        var commands = e.originalEvent.data;

        for (var command in commands) {
          var url = host + commandMap[command]
          var params = commands[command];

          $.getJSON(url + '?callback=?', params, function(response) {
            parent.postMessage({command: command, response: response}, location.protocol + '//' + location.host);
          });
        }
      });
    </script>
  </body>
</html>

<!DOCTYPE html>

<html>
  <head>
    <meta charset="utf-8" />
    <title></title>
  </head>

  <body>
    <script src="scripts/lib/jquery.js" type="text/javascript"></script>
    <script type="text/javascript">
      var host = 'https://login.zooniverse.org/';
      if (!!~location.host.indexOf('localhost')) host = 'http://localhost:3000';

      var commandMap = {
        'authenticate': '/login',
        'log-out': '/logout'
      };

      $(window).on('message', function(e) {
        var commands = e.originalEvent.data;

        for (var command in commands) {
          var url = host + commandMap[command]
          var params = commands[command];

          $.getJSON(url + '?callback=?', params, function(response) {
            parent.postMessage({command: command, response: response}, location.protocol + '//' + location.host);
          });
        }
      });

      // Check for current user.
      $.getJSON(host + '/current_user?callback=?', function(response) {
        if (response.success !== true) return;
        parent.postMessage({command: 'authenticate', response: response}, location.protocol + '//' + location.host);
      })
    </script>
  </body>
</html>

Check for current user on load.
Check for current user on load.