Commit 6ab46856 authored by Thibaut Frain's avatar Thibaut Frain

Corrected bug (no detection of some login error)

parent 75d7758a
......@@ -27,6 +27,9 @@
function isMessage(input) {
return input.nodeName === "message";
}
function getHash(gadget, options) {
return gadget.aq_pleasePublishMyState(options);
}
rJS(window).allowPublicAcquisition("manageService", function(params) {
this.props.app_services.monitor(params[0]);
}).allowPublicAcquisition("send", function(datas) {
......@@ -84,8 +87,16 @@
return this.getDeclaredGadget("connection").push(function(connection_gadget) {
return connection_gadget.getConnectionJID();
});
}).allowPublicAcquisition("redirectOptions", function(options) {
var gadget = this;
return getHash(this, options[0]).push(function(hash) {
if ("#" + window.location.href.split("#")[1] === hash) {
return gadget.render(options[0]);
}
window.location = hash;
});
}).allowPublicAcquisition("getHash", function(options) {
return this.aq_pleasePublishMyState(options[0]);
return getHash(this, options[0]);
}).declareAcquiredMethod("pleaseRedirectMyHash", "pleaseRedirectMyHash").allowPublicAcquisition("messagesAreRead", function(jid) {
return this.getDeclaredGadget("contactlist").push(function(contactlist_gadget) {
return contactlist_gadget.messagesAreRead(jid[0]);
......
/*global window, rJS, Strophe, $, $iq, Handlebars,
/*global window, rJS, Strophe, $, $iq, Handlebars, console,
XMLSerializer, DOMParser, RSVP, sessionStorage, promiseEventListener*/
/*jslint nomen: true*/
(function($, Strophe, rJS, Handlebars) {
......@@ -13,6 +13,7 @@
function logout(gadget, authfail) {
sessionStorage.removeItem("connection_params");
return gadget.render({
page: "connection",
authfail: authfail
});
}
......@@ -86,9 +87,13 @@
if (status === Strophe.Status.DISCONNECTED) {
return logout(gadget, authfail);
}
if (status === Strophe.Status.CONNFAIL || status === Strophe.Status.AUTHFAIL) {
if (status === Strophe.Status.CONNFAIL) {
authfail = true;
}
if (status === Strophe.Status.AUTHFAIL) {
authfail = true;
connection.disconnect();
}
}).fail(function(e) {
reject(e);
});
......@@ -102,7 +107,7 @@
server: options.server
};
return new RSVP.Queue().push(function() {
if (options && options.authfail) {
if (options && (options.authfail === "true" || options.authfail === true)) {
params.authfail = true;
}
$(gadget.__element).html(login_template(params));
......@@ -135,10 +140,12 @@
}
}).ready(function(g) {
g.props = {};
}).declareAcquiredMethod("pleaseRedirectMyHash", "pleaseRedirectMyHash").declareAcquiredMethod("getHash", "getHash").declareMethod("render", function(options) {
}).declareAcquiredMethod("pleaseRedirectMyHash", "pleaseRedirectMyHash").declareAcquiredMethod("redirectOptions", "redirectOptions").declareMethod("render", function(options) {
console.log("render connection");
console.log(options);
if (options.server === undefined) {
options.server = "https://mail.tiolive.com/chat/http-bind/";
return this.getHash(options).push(this.pleaseRedirectMyHash.bind(this));
return this.redirectOptions(options);
}
if (this.props.connection && this.props.connection.authenticated) {
return showLogout(this);
......
......@@ -36,6 +36,10 @@
return input.nodeName === "message";
}
function getHash(gadget, options) {
return gadget.aq_pleasePublishMyState(options);
}
rJS(window)
.allowPublicAcquisition('manageService', function (params) {
......@@ -122,8 +126,19 @@
});
})
.allowPublicAcquisition("redirectOptions", function (options) {
var gadget = this;
return getHash(this, options[0])
.push(function (hash) {
if ("#" + window.location.href.split("#")[1] === hash) {
return gadget.render(options[0]);
}
window.location = hash;
});
})
.allowPublicAcquisition('getHash', function (options) {
return this.aq_pleasePublishMyState(options[0]);
return getHash(this, options[0]);
})
.declareAcquiredMethod("pleaseRedirectMyHash", "pleaseRedirectMyHash")
......
......@@ -24,7 +24,10 @@
function logout(gadget, authfail) {
sessionStorage.removeItem("connection_params");
return gadget.render({authfail: authfail});
return gadget.render({
page: "connection",
authfail: authfail
});
}
function showLogout(gadget) {
......@@ -123,9 +126,12 @@
if (status === Strophe.Status.DISCONNECTED) {
return logout(gadget, authfail);
}
if (status === Strophe.Status.CONNFAIL ||
status === Strophe.Status.AUTHFAIL) {
if (status === Strophe.Status.CONNFAIL) {
authfail = true;
}
if (status === Strophe.Status.AUTHFAIL) {
authfail = true;
connection.disconnect();
}
})
.fail(function (e) {
......@@ -143,7 +149,8 @@
};
return new RSVP.Queue()
.push(function () {
if (options && options.authfail) {
if (options &&
(options.authfail === "true" || options.authfail === true)) {
params.authfail = true;
}
$(gadget.__element).html(login_template(params));
......@@ -210,13 +217,12 @@
.declareAcquiredMethod('pleaseRedirectMyHash', 'pleaseRedirectMyHash')
.declareAcquiredMethod('getHash', 'getHash')
.declareAcquiredMethod('redirectOptions', 'redirectOptions')
.declareMethod('render', function (options) {
if (options.server === undefined) {
options.server = "https://mail.tiolive.com/chat/http-bind/";
return this.getHash(options)
.push(this.pleaseRedirectMyHash.bind(this));
return this.redirectOptions(options);
}
if (this.props.connection &&
this.props.connection.authenticated) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment