Don't redirect until realtime is synced when logging in

pull/1/head
yflory 8 years ago
parent 0c1efd361b
commit a8d200ef2e

@ -132,8 +132,10 @@ define([
if (result.proxy && !result.proxy.login_name) { if (result.proxy && !result.proxy.login_name) {
result.proxy.login_name = result.userName; result.proxy.login_name = result.userName;
} }
Cryptpad.login(result.userHash, result.userName, function () { Cryptpad.whenRealtimeSyncs(result.realtime, function () {
document.location.href = '/drive/'; Cryptpad.login(result.userHash, result.userName, function () {
document.location.href = '/drive/';
});
}); });
return; return;
} }

@ -76,18 +76,21 @@ define([
if (result.proxy && !result.proxy.login_name) { if (result.proxy && !result.proxy.login_name) {
result.proxy.login_name = result.userName; result.proxy.login_name = result.userName;
} }
Cryptpad.login(result.userHash, result.userName, function () {
if (sessionStorage.redirectTo) { Cryptpad.whenRealtimeSyncs(result.realtime, function() {
var h = sessionStorage.redirectTo; Cryptpad.login(result.userHash, result.userName, function () {
var parser = document.createElement('a'); if (sessionStorage.redirectTo) {
parser.href = h; var h = sessionStorage.redirectTo;
if (parser.origin === window.location.origin) { var parser = document.createElement('a');
delete sessionStorage.redirectTo; parser.href = h;
window.location.href = h; if (parser.origin === window.location.origin) {
return; delete sessionStorage.redirectTo;
window.location.href = h;
return;
}
} }
} window.location.href = '/drive/';
window.location.href = '/drive/'; });
}); });
return; return;
} }

@ -42,7 +42,7 @@ define([
var obj = store.proxy; var obj = store.proxy;
var $div = $('<div>', {'class': 'infoBlock'}); var $div = $('<div>', {'class': 'infoBlock'});
var accountName = obj.login_name; var accountName = obj.login_name || localStorage[Cryptpad.userNameKey];
var $label = $('<span>', {'class': 'label'}).text(Messages.user_accountName + ':'); var $label = $('<span>', {'class': 'label'}).text(Messages.user_accountName + ':');
var $name = $('<span>').text(accountName || ''); var $name = $('<span>').text(accountName || '');
if (!accountName) { if (!accountName) {

Loading…
Cancel
Save