Skip to content
Snippets Groups Projects
sign_in.html 1.77 KiB
Newer Older
<!-- This Source Code Form is subject to the terms of the Mozilla Public
   - License, v. 2.0. If a copy of the MPL was not distributed with this
   - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->

<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1.0; maximum-scale=1.0; width=device-width;">
<title>
BrowserID Example Primary
</title>
<style type="text/css">
body { margin: auto; font: 13px/1.5 Helvetica, Arial, 'Liberation Sans', FreeSans, sans-serif; }
.title { font-size: 2em; font-weight: bold; text-align: center; margin: 1.5em; }
.intro { font-size: 1.2em; width: 600px; margin: auto; }
.main { text-align: center; margin-top: 2em; font-size: 1.2em; width: 500px; margin: auto; }
#who { font-weight: bold; }
#cancel { font-size: small; }
button { line-height: 20px; }

</style>
</head>
<body>
<div class="title">
  Sign into our example primary!
</div>

<div class="main" id="logged_out">
  Sign in as <span id="who">...</span>
  <button autofocus>doit</button>
</div>

<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="https://login.persona.org/authentication_api.js"></script>
<script type="text/javascript">


$(document).ready(function() {
  try {
    navigator.id.beginAuthentication(function(email) {
      who = /^([^@]+)@/.exec(email)[1];
      $('#who').text(who);
    });
  } catch(e) {
    alert("uh oh: " + e);
  }
  $("button").click(function(e) {
    $.get('/api/login', { user: who })
      .success(function(r) {
        navigator.id.completeAuthentication();

  $("#cancel").click(function(e) {
    e.preventDefault();
    navigator.id.raiseAuthenticationFailure('cancel');
});
</script>
</body>
</html>