Rename JSOpenID -> JSAutoLogin
This commit is contained in:
parent
5c48c8a57a
commit
68f3d3a458
2 changed files with 8 additions and 90 deletions
|
@ -2,20 +2,20 @@
|
||||||
* Copyright (c) 2014, Patrick Uiterwijk <puiterwijk@redhat.com>
|
* Copyright (c) 2014, Patrick Uiterwijk <puiterwijk@redhat.com>
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* This file is part of JSOpenID.
|
* This file is part of JSAutoLogin.
|
||||||
*
|
*
|
||||||
* JSOpenID is free software: you can redistribute it and/or modify
|
* JSAutoLogin is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* JSOpenID is distributed in the hope that it will be useful,
|
* JSAutoLogin is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with JSOpenID. If not, see <http://www.gnu.org/licenses/>.
|
* along with JSAutoLogin. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function respondToLogin(targetOrigin, success, data)
|
function respondToLogin(targetOrigin, success, data)
|
||||||
|
@ -25,7 +25,7 @@ function respondToLogin(targetOrigin, success, data)
|
||||||
if(window.parent != null)
|
if(window.parent != null)
|
||||||
{
|
{
|
||||||
// If we don't have this element in the parent window, this is not an auth iframe
|
// If we don't have this element in the parent window, this is not an auth iframe
|
||||||
if(window.parent.document.getElementById('jsopenid_ifrm') != null)
|
if(window.parent.document.getElementById('jsautologin_ifrm') != null)
|
||||||
{
|
{
|
||||||
window.parent.postMessage({"success": success,
|
window.parent.postMessage({"success": success,
|
||||||
"data": data},
|
"data": data},
|
||||||
|
@ -39,7 +39,7 @@ function tryBackgroundLogin(login_url, callback_success, callback_failed)
|
||||||
if(window.parent != null)
|
if(window.parent != null)
|
||||||
{
|
{
|
||||||
// Check if we are called recursively (from within a login attempt)
|
// Check if we are called recursively (from within a login attempt)
|
||||||
if(window.parent.document.getElementById('jsopenid_ifrm') != null)
|
if(window.parent.document.getElementById('jsautologin_ifrm') != null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ function tryBackgroundLogin(login_url, callback_success, callback_failed)
|
||||||
|
|
||||||
// Create the iframe we are going to use
|
// Create the iframe we are going to use
|
||||||
ifrm = document.createElement('iframe');
|
ifrm = document.createElement('iframe');
|
||||||
ifrm.id = 'jsopenid_ifrm';
|
ifrm.id = 'jsautologin_ifrm';
|
||||||
ifrm.src = login_url;
|
ifrm.src = login_url;
|
||||||
ifrm.style.width = 0;
|
ifrm.style.width = 0;
|
||||||
ifrm.style.height = 0;
|
ifrm.style.height = 0;
|
|
@ -1,83 +0,0 @@
|
||||||
/**
|
|
||||||
* Copyright (c) 2014, Patrick Uiterwijk <puiterwijk@redhat.com>
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* This file is part of JSOpenID.
|
|
||||||
*
|
|
||||||
* JSOpenID is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* JSOpenID is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with JSOpenID. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
function respondToLogin(targetOrigin, success, data)
|
|
||||||
{
|
|
||||||
// From an iframe, window.parent == parent window
|
|
||||||
// So if we don't have a window.parent, we're certainly not an iframe
|
|
||||||
if(window.parent != null)
|
|
||||||
{
|
|
||||||
// If we don't have this element in the parent window, this is not an auth iframe
|
|
||||||
if(window.parent.document.getElementById('jsopenid_ifrm') != null)
|
|
||||||
{
|
|
||||||
window.parent.postMessage({"success": success,
|
|
||||||
"data": data},
|
|
||||||
targetOrigin);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function tryBackgroundLogin(login_url, callback_success, callback_failed)
|
|
||||||
{
|
|
||||||
if(window.parent != null)
|
|
||||||
{
|
|
||||||
// Check if we are called recursively (from within a login attempt)
|
|
||||||
if(window.parent.document.getElementById('jsopenid_ifrm') != null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create the iframe we are going to use
|
|
||||||
ifrm = document.createElement('iframe');
|
|
||||||
ifrm.id = 'jsopenid_ifrm';
|
|
||||||
ifrm.src = login_url;
|
|
||||||
ifrm.style.width = 0;
|
|
||||||
ifrm.style.height = 0;
|
|
||||||
ifrm.style.visibility = "hidden";
|
|
||||||
|
|
||||||
// Set up for pingbacks
|
|
||||||
window.addEventListener('message', function(event)
|
|
||||||
{
|
|
||||||
// We don't check don't check event.origin, as it wouldn't add anything worthwhile
|
|
||||||
// This would prevent a rogue website from saying "The user is now logged in", but we should *never* trust this anyway
|
|
||||||
// This whole library is only for user convenience
|
|
||||||
if(event.source != ifrm.contentWindow)
|
|
||||||
{
|
|
||||||
// Ignoring response from someone unexpected
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
document.body.removeChild(ifrm);
|
|
||||||
if(event.data["success"])
|
|
||||||
{
|
|
||||||
callback_success(event.data["data"]);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if(callback_failed != null)
|
|
||||||
{
|
|
||||||
callback_failed(event.data["data"]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, false);
|
|
||||||
|
|
||||||
// HIT IT!
|
|
||||||
document.body.appendChild(ifrm);
|
|
||||||
}
|
|
1
roles/apps-fp-o/files/global/js/jsopenid.js
Symbolic link
1
roles/apps-fp-o/files/global/js/jsopenid.js
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
jsautologin.js
|
Loading…
Add table
Add a link
Reference in a new issue