diff --git a/src/hello.js b/src/hello.js index 3811b60d..7c7c04df 100644 --- a/src/hello.js +++ b/src/hello.js @@ -1285,6 +1285,13 @@ hello.utils.extend(hello.utils, { // If this is a page request it has no parent or opener window to handle callbacks if (('display' in obj) && obj.display === 'page') { + // Emit error event for page display mode if error exists + if (obj.error) { + hello.emit('error', { + network: network, + error: obj.error + }); + } return; } @@ -1452,6 +1459,14 @@ hello.utils.Event.call(hello); continue; } + // Check for errors in session + else if (session.error && !oldSess.error) { + // Emit the error event + hello.emit('error', { + network: name, + error: session.error + }); + } // Access_token has been removed else if (!session.access_token && oldSess.access_token) { emit('logout'); diff --git a/src/modules/instagram.js b/src/modules/instagram.js index 5079fbcf..12196bdf 100644 --- a/src/modules/instagram.js +++ b/src/modules/instagram.js @@ -15,7 +15,32 @@ // Refresh the access_token once expired refresh: true, - + logout: function(callback) { + // Instagram now requires POST method for logout instead of GET + // Using form submission via iframe to handle the logout + var form = document.createElement('form'); + form.method = 'POST'; + form.action = 'https://www.instagram.com/accounts/logout/'; + form.style.display = 'none'; + + var iframe = document.createElement('iframe'); + iframe.name = 'logout_frame'; + iframe.style.display = 'none'; + document.body.appendChild(iframe); + + form.target = 'logout_frame'; + document.body.appendChild(form); + + // Submit the form + form.submit(); + + // Clean up after a short delay + setTimeout(function() { + document.body.removeChild(form); + document.body.removeChild(iframe); + callback(); + }, 1000); + }, scope: { basic: 'basic', photos: '',