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

Corrected bug (no detection of some login error)

parent 75d7758a
...@@ -27,6 +27,9 @@ ...@@ -27,6 +27,9 @@
function isMessage(input) { function isMessage(input) {
return input.nodeName === "message"; return input.nodeName === "message";
} }
function getHash(gadget, options) {
return gadget.aq_pleasePublishMyState(options);
}
rJS(window).allowPublicAcquisition("manageService", function(params) { rJS(window).allowPublicAcquisition("manageService", function(params) {
this.props.app_services.monitor(params[0]); this.props.app_services.monitor(params[0]);
}).allowPublicAcquisition("send", function(datas) { }).allowPublicAcquisition("send", function(datas) {
...@@ -84,8 +87,16 @@ ...@@ -84,8 +87,16 @@
return this.getDeclaredGadget("connection").push(function(connection_gadget) { return this.getDeclaredGadget("connection").push(function(connection_gadget) {
return connection_gadget.getConnectionJID(); 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) { }).allowPublicAcquisition("getHash", function(options) {
return this.aq_pleasePublishMyState(options[0]); return getHash(this, options[0]);
}).declareAcquiredMethod("pleaseRedirectMyHash", "pleaseRedirectMyHash").allowPublicAcquisition("messagesAreRead", function(jid) { }).declareAcquiredMethod("pleaseRedirectMyHash", "pleaseRedirectMyHash").allowPublicAcquisition("messagesAreRead", function(jid) {
return this.getDeclaredGadget("contactlist").push(function(contactlist_gadget) { return this.getDeclaredGadget("contactlist").push(function(contactlist_gadget) {
return contactlist_gadget.messagesAreRead(jid[0]); return contactlist_gadget.messagesAreRead(jid[0]);
......
/*global window, rJS, Strophe, $, $iq, Handlebars, /*global window, rJS, Strophe, $, $iq, Handlebars, console,
XMLSerializer, DOMParser, RSVP, sessionStorage, promiseEventListener*/ XMLSerializer, DOMParser, RSVP, sessionStorage, promiseEventListener*/
/*jslint nomen: true*/ /*jslint nomen: true*/
(function($, Strophe, rJS, Handlebars) { (function($, Strophe, rJS, Handlebars) {
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
function logout(gadget, authfail) { function logout(gadget, authfail) {
sessionStorage.removeItem("connection_params"); sessionStorage.removeItem("connection_params");
return gadget.render({ return gadget.render({
page: "connection",
authfail: authfail authfail: authfail
}); });
} }
...@@ -86,9 +87,13 @@ ...@@ -86,9 +87,13 @@
if (status === Strophe.Status.DISCONNECTED) { if (status === Strophe.Status.DISCONNECTED) {
return logout(gadget, authfail); return logout(gadget, authfail);
} }
if (status === Strophe.Status.CONNFAIL || status === Strophe.Status.AUTHFAIL) { if (status === Strophe.Status.CONNFAIL) {
authfail = true; authfail = true;
} }
if (status === Strophe.Status.AUTHFAIL) {
authfail = true;
connection.disconnect();
}
}).fail(function(e) { }).fail(function(e) {
reject(e); reject(e);
}); });
...@@ -102,7 +107,7 @@ ...@@ -102,7 +107,7 @@
server: options.server server: options.server
}; };
return new RSVP.Queue().push(function() { return new RSVP.Queue().push(function() {
if (options && options.authfail) { if (options && (options.authfail === "true" || options.authfail === true)) {
params.authfail = true; params.authfail = true;
} }
$(gadget.__element).html(login_template(params)); $(gadget.__element).html(login_template(params));
...@@ -135,10 +140,12 @@ ...@@ -135,10 +140,12 @@
} }
}).ready(function(g) { }).ready(function(g) {
g.props = {}; 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) { if (options.server === undefined) {
options.server = "https://mail.tiolive.com/chat/http-bind/"; 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) { if (this.props.connection && this.props.connection.authenticated) {
return showLogout(this); return showLogout(this);
......
...@@ -36,6 +36,10 @@ ...@@ -36,6 +36,10 @@
return input.nodeName === "message"; return input.nodeName === "message";
} }
function getHash(gadget, options) {
return gadget.aq_pleasePublishMyState(options);
}
rJS(window) rJS(window)
.allowPublicAcquisition('manageService', function (params) { .allowPublicAcquisition('manageService', function (params) {
...@@ -122,8 +126,19 @@ ...@@ -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) { .allowPublicAcquisition('getHash', function (options) {
return this.aq_pleasePublishMyState(options[0]); return getHash(this, options[0]);
}) })
.declareAcquiredMethod("pleaseRedirectMyHash", "pleaseRedirectMyHash") .declareAcquiredMethod("pleaseRedirectMyHash", "pleaseRedirectMyHash")
......
...@@ -24,7 +24,10 @@ ...@@ -24,7 +24,10 @@
function logout(gadget, authfail) { function logout(gadget, authfail) {
sessionStorage.removeItem("connection_params"); sessionStorage.removeItem("connection_params");
return gadget.render({authfail: authfail}); return gadget.render({
page: "connection",
authfail: authfail
});
} }
function showLogout(gadget) { function showLogout(gadget) {
...@@ -123,9 +126,12 @@ ...@@ -123,9 +126,12 @@
if (status === Strophe.Status.DISCONNECTED) { if (status === Strophe.Status.DISCONNECTED) {
return logout(gadget, authfail); return logout(gadget, authfail);
} }
if (status === Strophe.Status.CONNFAIL || if (status === Strophe.Status.CONNFAIL) {
status === Strophe.Status.AUTHFAIL) { authfail = true;
}
if (status === Strophe.Status.AUTHFAIL) {
authfail = true; authfail = true;
connection.disconnect();
} }
}) })
.fail(function (e) { .fail(function (e) {
...@@ -143,7 +149,8 @@ ...@@ -143,7 +149,8 @@
}; };
return new RSVP.Queue() return new RSVP.Queue()
.push(function () { .push(function () {
if (options && options.authfail) { if (options &&
(options.authfail === "true" || options.authfail === true)) {
params.authfail = true; params.authfail = true;
} }
$(gadget.__element).html(login_template(params)); $(gadget.__element).html(login_template(params));
...@@ -210,13 +217,12 @@ ...@@ -210,13 +217,12 @@
.declareAcquiredMethod('pleaseRedirectMyHash', 'pleaseRedirectMyHash') .declareAcquiredMethod('pleaseRedirectMyHash', 'pleaseRedirectMyHash')
.declareAcquiredMethod('getHash', 'getHash') .declareAcquiredMethod('redirectOptions', 'redirectOptions')
.declareMethod('render', function (options) { .declareMethod('render', function (options) {
if (options.server === undefined) { if (options.server === undefined) {
options.server = "https://mail.tiolive.com/chat/http-bind/"; options.server = "https://mail.tiolive.com/chat/http-bind/";
return this.getHash(options) return this.redirectOptions(options);
.push(this.pleaseRedirectMyHash.bind(this));
} }
if (this.props.connection && if (this.props.connection &&
this.props.connection.authenticated) { 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