mirror of https://github.com/xwiki-labs/cryptpad
Move the 'logged out' screen inside the sframe
This commit is contained in:
parent
5a2afb5c95
commit
1514ad5df3
|
@ -1215,6 +1215,21 @@ define([
|
|||
}
|
||||
if (parsedNew) { oldHref = newHref; }
|
||||
};
|
||||
// Listen for login/logout in other tabs
|
||||
window.addEventListener('storage', function (e) {
|
||||
if (e.key !== common.userHashKey) { return; }
|
||||
var o = e.oldValue;
|
||||
var n = e.newValue;
|
||||
if (!o && n) {
|
||||
document.location.reload();
|
||||
} else if (o && !n) {
|
||||
common.logout();
|
||||
if (getNetwork()) {
|
||||
getNetwork().disconnect();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
if (PINNING_ENABLED && isLoggedIn()) {
|
||||
console.log("logged in. pads will be pinned");
|
||||
|
|
|
@ -304,28 +304,6 @@ define([
|
|||
|
||||
var exp = {};
|
||||
|
||||
window.addEventListener('storage', function (e) {
|
||||
if (e.key !== Cryptpad.userHashKey) { return; }
|
||||
var o = e.oldValue;
|
||||
var n = e.newValue;
|
||||
if (!o && n) {
|
||||
window.location.reload();
|
||||
} else if (o && !n) {
|
||||
$(window).on('keyup', function (e) {
|
||||
if (e.keyCode === 27) {
|
||||
//UI.removeLoadingScreen();
|
||||
}
|
||||
});
|
||||
Cryptpad.logout();
|
||||
UI.alert(Cryptpad.Messages.onLogout, null, true);
|
||||
//UI.addLoadingScreen({hideTips: true});
|
||||
//UI.errorLoadingScreen(Cryptpad.Messages.onLogout, true);
|
||||
if (exp.info) {
|
||||
exp.info.network.disconnect();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var rt = window.rt = Listmap.create(listmapConfig);
|
||||
|
||||
exp.realtime = rt.realtime;
|
||||
|
|
|
@ -440,7 +440,7 @@ define([
|
|||
});
|
||||
}, 2000);
|
||||
|
||||
//Cryptpad.onLogout(function () { ... });
|
||||
//common.onLogout(function () { ... });
|
||||
|
||||
Cryptpad.onError(function (info) {
|
||||
if (info && info.type === "store") {
|
||||
|
|
|
@ -101,6 +101,7 @@ define([
|
|||
secret.channel = Utils.Hash.createChannelId();
|
||||
}
|
||||
Cryptpad.getShareHashes(secret, waitFor(function (err, h) { hashes = h; }));
|
||||
|
||||
}).nThen(function () {
|
||||
var readOnly = secret.keys && !secret.keys.editKeyStr;
|
||||
if (!secret.keys) { secret.keys = secret.key; }
|
||||
|
@ -161,6 +162,10 @@ define([
|
|||
sframeChan.onReg('EV_METADATA_UPDATE', updateMeta);
|
||||
proxy.on('change', 'settings', updateMeta);
|
||||
|
||||
Cryptpad.onLogout(function () {
|
||||
sframeChan.event('EV_LOGOUT');
|
||||
});
|
||||
|
||||
Cryptpad.onError(function (info) {
|
||||
console.log('error');
|
||||
console.log(info);
|
||||
|
|
|
@ -314,6 +314,14 @@ define([
|
|||
|
||||
funcs.whenRealtimeSyncs = evRealtimeSynced.reg;
|
||||
|
||||
var logoutHandlers = [];
|
||||
funcs.onLogout = function (h) {
|
||||
if (typeof (h) !== "function") { return; }
|
||||
if (logoutHandlers.indexOf(h) !== -1) { return; }
|
||||
logoutHandlers.push(h);
|
||||
};
|
||||
|
||||
|
||||
Object.freeze(funcs);
|
||||
return { create: function (cb) {
|
||||
|
||||
|
@ -360,6 +368,19 @@ define([
|
|||
|
||||
UI.addTooltips();
|
||||
|
||||
ctx.sframeChan.on('EV_LOGOUT', function () {
|
||||
$(window).on('keyup', function (e) {
|
||||
if (e.keyCode === 27) {
|
||||
UI.removeLoadingScreen();
|
||||
}
|
||||
});
|
||||
UI.addLoadingScreen({hideTips: true});
|
||||
UI.errorLoadingScreen(Messages.onLogout, true);
|
||||
logoutHandlers.forEach(function (h) {
|
||||
if (typeof (h) === "function") { h(); }
|
||||
});
|
||||
});
|
||||
|
||||
ctx.sframeChan.on('EV_RT_CONNECT', function () { CommonRealtime.setConnectionState(true); });
|
||||
ctx.sframeChan.on('EV_RT_DISCONNECT', function () { CommonRealtime.setConnectionState(false); });
|
||||
|
||||
|
|
|
@ -56,6 +56,8 @@ define({
|
|||
|
||||
// Log the user out in all the tabs
|
||||
'Q_LOGOUT': true,
|
||||
// Tell the user that he has been logged out from outside (probably from another tab)
|
||||
'EV_LOGOUT': true,
|
||||
|
||||
// When moving to the login or register page from a pad, we need to redirect to that pad at the
|
||||
// end of the login process. This query set the current href to the sessionStorage.
|
||||
|
|
|
@ -1038,7 +1038,7 @@ define([
|
|||
initClickEvents(toolbar, config);
|
||||
initNotifications(toolbar, config);
|
||||
|
||||
toolbar.failed = function () {
|
||||
var failed = toolbar.failed = function () {
|
||||
toolbar.connected = false;
|
||||
|
||||
if (toolbar.spinner) {
|
||||
|
@ -1079,12 +1079,11 @@ define([
|
|||
};
|
||||
|
||||
// On log out, remove permanently the realtime elements of the toolbar
|
||||
// TODO
|
||||
/*Common.onLogout(function () {
|
||||
Common.onLogout(function () {
|
||||
failed();
|
||||
if (toolbar.useradmin) { toolbar.useradmin.hide(); }
|
||||
if (toolbar.userlist) { toolbar.userlist.hide(); }
|
||||
});*/
|
||||
});
|
||||
|
||||
return toolbar;
|
||||
};
|
||||
|
|
|
@ -3057,7 +3057,7 @@ define([
|
|||
onConnectError();
|
||||
}
|
||||
});
|
||||
//Cryptpad.onLogout(function () { setEditable(false); });
|
||||
common.onLogout(function () { setEditable(false); });
|
||||
});
|
||||
};
|
||||
main();
|
||||
|
|
|
@ -629,7 +629,7 @@ define([
|
|||
saveImage();
|
||||
});
|
||||
|
||||
Cryptpad.onLogout(function () { setEditable(false); });
|
||||
common.onLogout(function () { setEditable(false); });
|
||||
};
|
||||
|
||||
var main = function () {
|
||||
|
|
Loading…
Reference in New Issue