mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-24 06:35:49 +03:00
Stopped browser-auth editing src of auth-pages frame
refs #36 This removes the behaviour of forcing the `src` property to change when opening the auth pages and insteads posts a message "asking" the auth pages to update the location hash.
This commit is contained in:
parent
550ea70c9c
commit
474c495331
@ -11,6 +11,11 @@ module.exports = function layer2(options) {
|
||||
container
|
||||
});
|
||||
|
||||
function postMessage(frame, data) {
|
||||
var origin = new URL(frame.getAttribute('src')).origin;
|
||||
frame.contentWindow.postMessage(data, origin);
|
||||
}
|
||||
|
||||
var loadAuth = loadFrame(authUrl, container).then(function (frame) {
|
||||
frame.style.position = 'fixed';
|
||||
frame.style.width = '100%';
|
||||
@ -24,7 +29,7 @@ module.exports = function layer2(options) {
|
||||
function openAuth(hash, query = '') {
|
||||
return loadAuth.then(function (frame) {
|
||||
return new Promise(function (resolve) {
|
||||
frame.src = `${authUrl}#${hash}?${query}`;
|
||||
postMessage(frame, {hash, query});
|
||||
frame.style.display = 'block';
|
||||
window.addEventListener('message', function messageListener(event) {
|
||||
if (event.source !== frame.contentWindow) {
|
||||
|
Loading…
Reference in New Issue
Block a user