From 340873769399ba611e955a662249ab43e81ed049 Mon Sep 17 00:00:00 2001 From: yanas Date: Wed, 20 Apr 2016 14:02:16 -0500 Subject: [PATCH 1/2] Adds id and password initial login --- connection.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/connection.js b/connection.js index aa0ca0f7c..3101ade40 100644 --- a/connection.js +++ b/connection.js @@ -22,7 +22,7 @@ function checkForAttachParametersAndConnect(id, password, connection) { // When connection optimization is not deployed or enabled the default // value will be window.XMPPAttachInfo.status = "error" // If the connection optimization is deployed and enabled and there is - // a failure the value will be window.XMPPAttachInfo.status = "error" + // a failure the value will be window.XMPPAttachInfo.status = "error" if(window.XMPPAttachInfo.status === "error") { connection.connect({id, password}); return; @@ -131,6 +131,20 @@ function requestAuth() { * @returns {Promise} */ export function openConnection({id, password, retry, roomName}) { + + let predefinedLogin = window.localStorage.getItem("xmpp_login"); + let predefinedPassword = window.localStorage.getItem("xmpp_password"); + + if (!id && predefinedLogin && predefinedLogin.length > 0) { + id = predefinedLogin; + window.localStorage.removeItem("xmpp_login"); + } + + if (!password && predefinedPassword && predefinedPassword.length > 0) { + password = predefinedPassword; + window.localStorage.removeItem("xmpp_password"); + } + return connect(id, password, roomName).catch(function (err) { if (!retry) { throw err; From 1c9903642b6aa0026f3eb560dc8dccd32d2f043b Mon Sep 17 00:00:00 2001 From: yanas Date: Wed, 20 Apr 2016 14:41:29 -0500 Subject: [PATCH 2/2] Do not remove the login params after read --- connection.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/connection.js b/connection.js index 3101ade40..7764dfe92 100644 --- a/connection.js +++ b/connection.js @@ -137,12 +137,10 @@ export function openConnection({id, password, retry, roomName}) { if (!id && predefinedLogin && predefinedLogin.length > 0) { id = predefinedLogin; - window.localStorage.removeItem("xmpp_login"); } if (!password && predefinedPassword && predefinedPassword.length > 0) { password = predefinedPassword; - window.localStorage.removeItem("xmpp_password"); } return connect(id, password, roomName).catch(function (err) {