X-Git-Url: https://git-public.kairo.at/?p=lantea.git;a=blobdiff_plain;f=js%2Floginwindow.js;fp=js%2Floginwindow.js;h=94cd6c2ca63e44cd38eafe13329eb80b308ccb5c;hp=0000000000000000000000000000000000000000;hb=c53a1969fd519687ca4d581077c8dc3792169bb8;hpb=5e9f4a24c890ea34a762380ac01d76648a8547e5 diff --git a/js/loginwindow.js b/js/loginwindow.js new file mode 100644 index 0000000..94cd6c2 --- /dev/null +++ b/js/loginwindow.js @@ -0,0 +1,22 @@ +/* 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/. */ + +window.onload = function() { + // Complete the login process by calling the main window. + if (window.opener) { + window.opener.finishLogin(getParameterByName("code"), getParameterByName("state")); + window.close(); + } + else { + document.getElementById("logininfo").textContent = "You have called this document outside of the login flow, which is not supported."; + } +} + +function getParameterByName(aName) { + // from http://stackoverflow.com/questions/901115/how-can-i-get-query-string-values-in-javascript + name = aName.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]"); + var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"), + results = regex.exec(location.search); + return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " ")); +}