Stop ask to re-link forever

Clear the registration flag when we detect that our credentials have
been invalidated, but retain the knowledge that we've been registered
before, so as to preserve post-first-install behaviors like skipping the
introductory install screens, and accessing the main ui.

Fix #541

// FREEBIE
This commit is contained in:
lilia 2016-01-11 16:08:54 -08:00
parent 04a5aa71b6
commit 5223e6ed30
3 changed files with 12 additions and 4 deletions

View file

@ -40,9 +40,10 @@
extension.onLaunched(function() { extension.onLaunched(function() {
console.log('extension launched'); console.log('extension launched');
storage.onready(function() { storage.onready(function() {
if (textsecure.registration.isDone()) { if (textsecure.registration.everDone()) {
openInbox(); openInbox();
} else { }
if (!textsecure.registration.isDone()) {
extension.install(); extension.install();
} }
}); });
@ -180,6 +181,7 @@
console.log(e.stack); console.log(e.stack);
if (e.name === 'HTTPError' && (e.code == 401 || e.code == 403)) { if (e.name === 'HTTPError' && (e.code == 401 || e.code == 403)) {
textsecure.registration.remove();
extension.install(); extension.install();
return; return;
} }

View file

@ -165,13 +165,19 @@
window.textsecure = window.textsecure || {}; window.textsecure = window.textsecure || {};
window.textsecure.registration = { window.textsecure.registration = {
done: function () { done: function () {
storage.put("chromiumRegistrationDoneEver", "");
storage.put("chromiumRegistrationDone", ""); storage.put("chromiumRegistrationDone", "");
extension.trigger('registration_done'); extension.trigger('registration_done');
}, },
isDone: function () { isDone: function () {
return storage.get("chromiumRegistrationDone") === ""; return storage.get("chromiumRegistrationDone") === "";
}, },
everDone: function() {
return storage.get("chromiumRegistrationDoneEver") === "";
},
remove: function() {
storage.remove("chromiumRegistrationDone");
},
}; };
extension.install = function(mode) { extension.install = function(mode) {

View file

@ -21,7 +21,7 @@
el: $('#install'), el: $('#install'),
deviceName: deviceName deviceName: deviceName
}); });
if (bg.textsecure.registration.isDone()) { if (bg.textsecure.registration.everDone()) {
view.selectStep(3); view.selectStep(3);
} }
view.$el.show(); view.$el.show();