diff --git a/lib/core/auth.js b/lib/core/auth.js index 0414217..c33c9cd 100644 --- a/lib/core/auth.js +++ b/lib/core/auth.js @@ -1,12 +1,14 @@ var token = null, session = null, isKW, + isElectron, auth, xdAuth; module.exports = function (config) { config = config ? config : require('../config'); isKW = config.WORLD_URL.indexOf(location.origin.replace(/(http:|https:)/, '')) !== -1; + isElectron = navigator.userAgent.indexOf("Electron") > -1; apiService = require('./kano-api')(config); xdAuth = require('./xd-auth')(config); @@ -23,7 +25,7 @@ module.exports = function (config) { } else { localStorage.setItem('KW_TOKEN', token); } - if (!disableCross && !isKW) { + if (!disableCross && !isKW && !isElectron) { xdAuth.setToken(token); } }, @@ -39,7 +41,7 @@ module.exports = function (config) { logout: function (reload) { reload = typeof reload === 'undefined' ? true : reload; auth.setToken(null); - if (!isKW) { + if (!isKW && !isElectron) { xdAuth.crossLogout(function (err) { if (reload) { location.reload(); @@ -68,8 +70,8 @@ module.exports = function (config) { }); } - // The current website is KW, we read directly the locaStorage - if (isKW) { + // The current website is either KW or running inside Electron, we read directly the locaStorage + if (isKW || isElectron) { p = onToken(token || localStorage.getItem('KW_TOKEN')); } // Otherwise, contact KW to get the toekn throught the iframe