Line | |
---|
1 | #HTTP_HEADER{Content-Type: text/javascript; charset=#CHARSET} |
---|
2 | /* |
---|
3 | * Plugin BrowserID pour SPIP |
---|
4 | * |
---|
5 | * (c) Fil 2012 - Licence GNU/GPL |
---|
6 | * |
---|
7 | */ |
---|
8 | |
---|
9 | [(#INCLURE{javascript/browserid.js})] |
---|
10 | |
---|
11 | /* |
---|
12 | * fonction demandant au client de verifier l'assertion renvoyee |
---|
13 | * par browserid |
---|
14 | */ |
---|
15 | function browserid_verify_client(assertion) { |
---|
16 | if (assertion) { |
---|
17 | $.post("https://browserid.org/verify", |
---|
18 | { |
---|
19 | assertion: assertion, |
---|
20 | audience: window.location.href.replace(/(\/\/.*?)\/.*/, '$1') |
---|
21 | }, browserid_welcome |
---|
22 | ); |
---|
23 | } |
---|
24 | } |
---|
25 | |
---|
26 | |
---|
27 | /* |
---|
28 | * fonction demandant au serveur de verifier l'assertion browserid |
---|
29 | * et de nous loger sur SPIP au passage, si le site est ainsi configure' |
---|
30 | */ |
---|
31 | function browserid_verify_server(assertion) { |
---|
32 | if (assertion) { |
---|
33 | $.post("?action=browserid_verify", |
---|
34 | { |
---|
35 | assertion: assertion, |
---|
36 | audience: window.location.href.replace(/(\/\/.*?)\/.*/, '$1') |
---|
37 | }, browserid_welcome |
---|
38 | ); |
---|
39 | } |
---|
40 | } |
---|
41 | |
---|
42 | |
---|
43 | /* |
---|
44 | * Fonction appelee quand on a reussi a se connecter |
---|
45 | */ |
---|
46 | function browserid_welcome(e) { |
---|
47 | // console.log(e); |
---|
48 | if (e.status == "okay") { |
---|
49 | if (url) { |
---|
50 | if (e.autoriser_ecrire) { |
---|
51 | window.location = url; |
---|
52 | } else { |
---|
53 | e.message = "Vous êtes identifié comme " + e.email + " mais cet email n'a pas d'accès à l'espace privé du site."; |
---|
54 | } |
---|
55 | } |
---|
56 | if (e.message) { |
---|
57 | browserid_message(e.message); |
---|
58 | } |
---|
59 | if (e.action) { |
---|
60 | eval(e.action); |
---|
61 | } |
---|
62 | } else { |
---|
63 | browserid_message('something was wrong: '+(e.reason || "")); |
---|
64 | } |
---|
65 | } |
---|
66 | |
---|
67 | /* definir a minima une fonction d'alerte */ |
---|
68 | if (!browserid_message) browserid_message = alert; |
---|
Note: See
TracBrowser
for help on using the repository browser.