Mercurial > hg > bitsyauth
annotate example/persona.html @ 39:8255e769828b
example/wsgibrowserid_example.py example/wsgibrowserid.py
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Fri, 27 Dec 2013 20:02:00 -0800 |
parents | 6b5946843928 |
children | cb1d21648588 |
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 |
32 | 10 <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.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> |
33 | 13 $(document).ready(function() { |
28 | 14 |
30
0bf52646061b
example/persona.html example/persona.py setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
29
diff
changeset
|
15 var currentUser = null; |
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 navigator.id.watch({ |
0bf52646061b
example/persona.html example/persona.py setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
29
diff
changeset
|
18 loggedInUser: currentUser, |
0bf52646061b
example/persona.html example/persona.py setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
29
diff
changeset
|
19 onlogin: function(assertion) { |
0bf52646061b
example/persona.html example/persona.py setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
29
diff
changeset
|
20 // 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
|
21 // 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
|
22 // 2. Update your UI. |
0bf52646061b
example/persona.html example/persona.py setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
29
diff
changeset
|
23 $.ajax({ |
0bf52646061b
example/persona.html example/persona.py setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
29
diff
changeset
|
24 type: 'POST', |
0bf52646061b
example/persona.html example/persona.py setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
29
diff
changeset
|
25 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
|
26 data: {assertion: assertion}, |
0bf52646061b
example/persona.html example/persona.py setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
29
diff
changeset
|
27 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
|
28 error: function(xhr, status, err) { |
0bf52646061b
example/persona.html example/persona.py setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
29
diff
changeset
|
29 navigator.id.logout(); |
0bf52646061b
example/persona.html example/persona.py setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
29
diff
changeset
|
30 alert("Login failure: " + err); |
0bf52646061b
example/persona.html example/persona.py setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
29
diff
changeset
|
31 } |
0bf52646061b
example/persona.html example/persona.py setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
29
diff
changeset
|
32 }); |
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 onlogout: function() { |
0bf52646061b
example/persona.html example/persona.py setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
29
diff
changeset
|
35 // 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
|
36 // 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
|
37 // 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
|
38 // (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
|
39 $.ajax({ |
0bf52646061b
example/persona.html example/persona.py setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
29
diff
changeset
|
40 type: 'POST', |
0bf52646061b
example/persona.html example/persona.py setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
29
diff
changeset
|
41 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
|
42 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
|
43 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
|
44 }); |
0bf52646061b
example/persona.html example/persona.py setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
29
diff
changeset
|
45 } |
0bf52646061b
example/persona.html example/persona.py setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
29
diff
changeset
|
46 }); |
28 | 47 |
23
21124b238feb
stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
48 var signinLink = document.getElementById('signin'); |
21124b238feb
stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
49 if (signinLink) { |
28 | 50 signinLink.onclick = function() { navigator.id.request(); }; |
23
21124b238feb
stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
51 } |
21124b238feb
stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
52 |
21124b238feb
stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
53 var signoutLink = document.getElementById('signout'); |
21124b238feb
stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
54 if (signoutLink) { |
37
6b5946843928
example/persona.html example/wsgibrowserid.py
Jeff Hammel <jhammel@mozilla.com>
parents:
34
diff
changeset
|
55 signoutLink.onclick = function() { navigator.id.logout(); }; |
23
21124b238feb
stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
56 } |
33 | 57 }); |
23
21124b238feb
stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
58 </script> |
21124b238feb
stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
59 </head> |
21124b238feb
stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
60 |
30
0bf52646061b
example/persona.html example/persona.py setup.py
Jeff Hammel <jhammel@mozilla.com>
parents:
29
diff
changeset
|
61 <body> |
23
21124b238feb
stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
62 <h1> |
21124b238feb
stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
63 <a href="https://login.persona.org/">Mozilla persona</a> |
21124b238feb
stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
64 <a href="http://k0s.org/hg/bitsyauth/">bitsyauth</a> |
21124b238feb
stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
65 test page |
21124b238feb
stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
66 </h1> |
21124b238feb
stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
67 |
21124b238feb
stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
68 <div> |
21124b238feb
stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
69 <a id="signin">sign in</a> |
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 |
21124b238feb
stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
72 <h2>Resources</h2> |
21124b238feb
stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
73 <ul> |
21124b238feb
stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
74 <li> |
21124b238feb
stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
75 <a href="https://developer.mozilla.org/en-US/Persona/branding"> |
21124b238feb
stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
76 branding |
21124b238feb
stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
77 </a>: |
21124b238feb
stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
78 buttons and what not |
21124b238feb
stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
79 </li> |
21124b238feb
stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
80 </ul> |
21124b238feb
stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
81 |
21124b238feb
stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
82 </body> |
21124b238feb
stub persona/browserid example
Jeff Hammel <jhammel@mozilla.com>
parents:
diff
changeset
|
83 </html> |