<!DOCTYPE html>
<html>
  <head>
    <script type="text/javascript">
      function getParameterByName(name) {
          name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
          var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
              results = regex.exec(location.search);
          return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
      }
      var next = getParameterByName('next');
      window.opener.location.href = {% if redirect_to %}"{{ redirect_to|escapejs }}" {% else %}next || '/'{% endif %};
      window.close();
    </script>
  </head>
<html>
