]> sipb.mit.edu Git - wiki.git/blob - names/webathena-login.js
add name change tool
[wiki.git] / names / webathena-login.js
1 (function () {
2     var WEBATHENA_HOST = "https://webathena.mit.edu";
3     var REALM = "ATHENA.MIT.EDU";
4         var PRINCIPAL = ["moira", "moira7.mit.edu"];
5
6     var button = document.getElementById("login");
7     button.addEventListener("click", function (ev) {
8                 document.getElementById("loading").hidden = false;
9
10                 WinChan.open({
11                         url: WEBATHENA_HOST + "/#!request_ticket_v1",
12                         relay_url: WEBATHENA_HOST + "/relay.html",
13                         params: {
14                                 realm: REALM,
15                                 principal: PRINCIPAL,
16                         }
17                 },
18                 function (err, r) {
19                         if (err) {
20                                         console.log(err);
21                                         window.alert(err);
22                                         return;
23                         }
24                                 if (r.status !== "OK") {
25                                         console.log(r);
26                                         if (r.code == "BAD_ORIGIN") {
27                                                 window.alert("Please use HTTPS to connect to this URL");
28                                         }
29                                         return;
30                                 }
31                                 console.log(r);
32                                 var session = JSON.stringify(r.session);
33
34                                 // Store the encoded ticket as a global variable
35                                 webathena_base64 = btoa(session);
36
37                                 onLogin();
38                         });
39         });
40 })();