Mercurial > hg > bitsyauth
annotate example/persona.html @ 31:6af220013aa1
example/persona.py setup.py
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Fri, 27 Dec 2013 12:13:18 -0800 |
parents | 0bf52646061b |
children | f462dc131d57 |
rev | line source |
---|---|
23
21124b238feb
stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> |
21124b238feb
stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
2 <html> |
21124b238feb
stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
3 <head> |
21124b238feb
stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
4 <title>bistyauth Mozilla persona test page</title> |
21124b238feb
stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
5 |
21124b238feb
stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
6 <!-- Suppressing Compatability Mode for IE |
21124b238feb
stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
7 https://developer.mozilla.org/en-US/Persona/Quick_Setup?redirectlocale=en-US&redirectslug=Persona%2FQuick_Setup#Suppressing_Compatibility_Mode --> |
21124b238feb
stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
8 <meta http-equiv="X-UA-Compatible" content="IE=Edge"> |
21124b238feb
stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
9 |
29 | 10 <script src="http://code.jquery.com/jquery-1.10.2.min.js"></script> |
23
21124b238feb
stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
11 <script src="https://login.persona.org/include.js"></script> |
21124b238feb
stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
12 <script> |
28 | 13 function onload() { |
14 | |
30
0bf52646061b
example/persona.html example/persona.py setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
29
diff
changeset
|
15 //alert("page loaded!"); |
0bf52646061b
example/persona.html example/persona.py setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
29
diff
changeset
|
16 |
0bf52646061b
example/persona.html example/persona.py setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
29
diff
changeset
|
17 var currentUser = null; |
0bf52646061b
example/persona.html example/persona.py setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
29
diff
changeset
|
18 |
0bf52646061b
example/persona.html example/persona.py setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
29
diff
changeset
|
19 navigator.id.watch({ |
0bf52646061b
example/persona.html example/persona.py setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
29
diff
changeset
|
20 loggedInUser: currentUser, |
0bf52646061b
example/persona.html example/persona.py setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
29
diff
changeset
|
21 onlogin: function(assertion) { |
0bf52646061b
example/persona.html example/persona.py setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
29
diff
changeset
|
22 // A user has logged in! Here you need to: |
0bf52646061b
example/persona.html example/persona.py setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
29
diff
changeset
|
23 // 1. Send the assertion to your backend for verification and to create a session. |
0bf52646061b
example/persona.html example/persona.py setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
29
diff
changeset
|
24 // 2. Update your UI. |
0bf52646061b
example/persona.html example/persona.py setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
29
diff
changeset
|
25 $.ajax({ |
0bf52646061b
example/persona.html example/persona.py setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
29
diff
changeset
|
26 type: 'POST', |
0bf52646061b
example/persona.html example/persona.py setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
29
diff
changeset
|
27 url: '/auth/login', // This is a URL on your website. |
0bf52646061b
example/persona.html example/persona.py setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
29
diff
changeset
|
28 data: {assertion: assertion}, |
0bf52646061b
example/persona.html example/persona.py setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
29
diff
changeset
|
29 success: function(res, status, xhr) { window.location.reload(); }, |
0bf52646061b
example/persona.html example/persona.py setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
29
diff
changeset
|
30 error: function(xhr, status, err) { |
0bf52646061b
example/persona.html example/persona.py setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
29
diff
changeset
|
31 navigator.id.logout(); |
0bf52646061b
example/persona.html example/persona.py setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
29
diff
changeset
|
32 alert("Login failure: " + err); |
0bf52646061b
example/persona.html example/persona.py setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
29
diff
changeset
|
33 } |
0bf52646061b
example/persona.html example/persona.py setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
29
diff
changeset
|
34 }); |
0bf52646061b
example/persona.html example/persona.py setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
29
diff
changeset
|
35 }, |
0bf52646061b
example/persona.html example/persona.py setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
29
diff
changeset
|
36 onlogout: function() { |
0bf52646061b
example/persona.html example/persona.py setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
29
diff
changeset
|
37 // A user has logged out! Here you need to: |
0bf52646061b
example/persona.html example/persona.py setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
29
diff
changeset
|
38 // Tear down the user's session by redirecting the user or making a call to your backend. |
0bf52646061b
example/persona.html example/persona.py setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
29
diff
changeset
|
39 // Also, make sure loggedInUser will get set to null on the next page load. |
0bf52646061b
example/persona.html example/persona.py setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
29
diff
changeset
|
40 // (That's a literal JavaScript null. Not false, 0, or undefined. null.) |
0bf52646061b
example/persona.html example/persona.py setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
29
diff
changeset
|
41 $.ajax({ |
0bf52646061b
example/persona.html example/persona.py setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
29
diff
changeset
|
42 type: 'POST', |
0bf52646061b
example/persona.html example/persona.py setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
29
diff
changeset
|
43 url: '/auth/logout', // This is a URL on your website. |
0bf52646061b
example/persona.html example/persona.py setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
29
diff
changeset
|
44 success: function(res, status, xhr) { window.location.reload(); }, |
0bf52646061b
example/persona.html example/persona.py setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
29
diff
changeset
|
45 error: function(xhr, status, err) { alert("Logout failure: " + err); } |
0bf52646061b
example/persona.html example/persona.py setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
29
diff
changeset
|
46 }); |
0bf52646061b
example/persona.html example/persona.py setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
29
diff
changeset
|
47 } |
0bf52646061b
example/persona.html example/persona.py setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
29
diff
changeset
|
48 }); |
28 | 49 |
23
21124b238feb
stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
50 var signinLink = document.getElementById('signin'); |
21124b238feb
stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
51 if (signinLink) { |
28 | 52 signinLink.onclick = function() { navigator.id.request(); }; |
23
21124b238feb
stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
53 } |
21124b238feb
stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
54 |
21124b238feb
stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
55 var signoutLink = document.getElementById('signout'); |
21124b238feb
stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
56 if (signoutLink) { |
21124b238feb
stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
57 signoutLink.onclick = function() { navigator.id.logout(); }; |
21124b238feb
stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
58 } |
28 | 59 } |
23
21124b238feb
stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
60 </script> |
21124b238feb
stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
61 </head> |
21124b238feb
stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
62 |
30
0bf52646061b
example/persona.html example/persona.py setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
29
diff
changeset
|
63 <body> |
23
21124b238feb
stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
64 <h1> |
21124b238feb
stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
65 <a href="https://login.persona.org/">Mozilla persona</a> |
21124b238feb
stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
66 <a href="http://k0s.org/hg/bitsyauth/">bitsyauth</a> |
21124b238feb
stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
67 test page |
21124b238feb
stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
68 </h1> |
21124b238feb
stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
69 |
21124b238feb
stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
70 <div> |
21124b238feb
stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
71 <a id="signin">sign in</a> |
21124b238feb
stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
72 </div> |
21124b238feb
stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
73 |
21124b238feb
stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
74 <h2>Resources</h2> |
21124b238feb
stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
75 <ul> |
21124b238feb
stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
76 <li> |
21124b238feb
stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
77 <a href="https://developer.mozilla.org/en-US/Persona/branding"> |
21124b238feb
stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
78 branding |
21124b238feb
stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
79 </a>: |
21124b238feb
stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
80 buttons and what not |
21124b238feb
stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
81 </li> |
21124b238feb
stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
82 </ul> |
21124b238feb
stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
83 |
21124b238feb
stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
84 </body> |
21124b238feb
stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
85 </html> |