summaryrefslogtreecommitdiff
path: root/frontend
authorClipperz <info@clipperz.com>2013-01-08 15:17:30 (UTC)
committer Clipperz <info@clipperz.com>2013-01-08 15:17:30 (UTC)
commit267603e3aa3cf0029411e67ae14018b52344c296 (patch) (side-by-side diff)
tree055e8f8d8543ed6bfa342dbf4641fea308c2ec5a /frontend
parentb6a11a37ec3271bd44fc23b9da00c5b052b0d8b9 (diff)
downloadclipperz-267603e3aa3cf0029411e67ae14018b52344c296.zip
clipperz-267603e3aa3cf0029411e67ae14018b52344c296.tar.gz
clipperz-267603e3aa3cf0029411e67ae14018b52344c296.tar.bz2
Fixed corrupted card problem
Changes that check for a weird condition that was causing cards to get corrupted. A similar change has been applied also to /gamma (in a different commit, though)
Diffstat (limited to 'frontend') (more/less context) (show whitespace changes)
-rw-r--r--frontend/beta/js/Clipperz/PM/Connection.js9
-rw-r--r--frontend/beta/js/Clipperz/PM/DataModel/Record.js12
-rw-r--r--frontend/beta/js/Clipperz/PM/DataModel/User.js17
3 files changed, 24 insertions, 14 deletions
diff --git a/frontend/beta/js/Clipperz/PM/Connection.js b/frontend/beta/js/Clipperz/PM/Connection.js
index 85aea21..e81c7a6 100644
--- a/frontend/beta/js/Clipperz/PM/Connection.js
+++ b/frontend/beta/js/Clipperz/PM/Connection.js
@@ -283,37 +283,41 @@ deferredResult.addErrback(MochiKit.Base.bind(function(res) {MochiKit.Logging.log
//deferredResult.addErrback(function(res) {MochiKit.Logging.logDebug("ERROR: " + res); return res;});
deferredResult.addCallback(MochiKit.Base.method(Clipperz.PM.Proxy.defaultProxy, 'handshake'));
//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("1.3.7 - Connection.login - 7: "/* + res*/); return res;});
//deferredResult.addErrback(function(res) {MochiKit.Logging.logDebug("ERROR: " + res); return res;});
//# deferredResult.addCallback(MochiKit.Base.method(this, 'loginDone'));
deferredResult.addCallback(MochiKit.Base.bind(function(someParameters) {
var result;
//MochiKit.Logging.logDebug(">>> Connection.loginDone: " + this + " (M2: " + this.srpConnection().M2() + ")");
if (someParameters['M2'] == this.srpConnection().M2()) {
result = new MochiKit.Async.Deferred();
//MochiKit.Logging.logDebug("--- Connection.loginDone - someParameters: " + Clipperz.Base.serializeJSON(someParameters));
this.setConnectionId(someParameters['connectionId']);
this.user().setLoginInfo(someParameters['loginInfo']);
this.user().setShouldDownloadOfflineCopy(someParameters['offlineCopyNeeded']);
- this.user().setLock(someParameters['lock']);
+
+ if ((isReconnecting == true) && (this.user().lock() != someParameters['lock'])) {
+ throw Clipperz.PM.Connection.exception.StaleData;
+ }
if (this.oneTimePassword() != null) {
result.addCallback(MochiKit.Base.method(this.user().oneTimePasswordManager(), 'archiveOneTimePassword', this.oneTimePassword()));
}
+
result.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'connection_loggedIn');
result.addCallback(MochiKit.Async.succeed, someParameters);
result.callback();
//MochiKit.Logging.logDebug("--- Connection.loginDone - 1 - result: "/* + Clipperz.Base.serializeJSON(result)*/);
} else {
//MochiKit.Logging.logDebug("--- Connection.loginDone - 2 - ERROR");
//deferredResult.addErrback(function(res) {MochiKit.Logging.logDebug("ERROR: " + res); return res;});
result = MochiKit.Async.fail(Clipperz.PM.Connection.exception.WrongChecksum);
}
//MochiKit.Logging.logDebug("<<< Connection.loginDone - result: " + Clipperz.Base.serializeJSON(result));
return result;
}, this));
//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("1.3.8 - Connection.login - 8: "/* + res*/); return res;});
@@ -564,18 +568,19 @@ Clipperz.PM.Connection.SRP['1.1'].prototype = MochiKit.Base.update(new Clipperz.
return this._P;
},
//-----------------------------------------------------------------------------
'hash': function() {
return Clipperz.PM.Crypto.encryptingFunctions.versions['0.2'].hash;
},
//-----------------------------------------------------------------------------
__syntaxFix__: "syntax fix"
});
Clipperz.PM.Connection.exception = {
- WrongChecksum: new MochiKit.Base.NamedError("Clipperz.ByteArray.exception.InvalidValue")
+ WrongChecksum: new MochiKit.Base.NamedError("Clipperz.ByteArray.exception.InvalidValue"),
+ StaleData: new MochiKit.Base.NamedError("Stale data")
};
diff --git a/frontend/beta/js/Clipperz/PM/DataModel/Record.js b/frontend/beta/js/Clipperz/PM/DataModel/Record.js
index ffb45de..ecb6c37 100644
--- a/frontend/beta/js/Clipperz/PM/DataModel/Record.js
+++ b/frontend/beta/js/Clipperz/PM/DataModel/Record.js
@@ -626,37 +626,39 @@ console.log("Record.processData - currentVersionParameters", currentVersionParam
aDirectLogin.record().user().synchronizeDirectLogin(aDirectLogin);
});
MochiKit.Iter.forEach(this.removedDirectLogins(), function(aDirectLogin) {
aDirectLogin.record().user().removeDirectLogin(aDirectLogin);
});
this.resetRemovedDirectLogins();
//MochiKit.Logging.logDebug("<<< Record.syncDirectLoginReferenceValues");
},
//-------------------------------------------------------------------------
'saveChanges': function() {
var result;
- if (this.isBrandNew() == false) {
- result = this.user().saveRecords([this], 'updateData');
- } else {
- result = this.user().saveRecords([this], 'addNewRecords');
- }
+// if (this.isBrandNew() == false) {
+// result = this.user().saveRecords([this], 'updateData');
+// } else {
+// result = this.user().saveRecords([this], 'addNewRecords');
+// }
+
+ result = this.user().saveRecords([this]);
return result;
},
/*
'saveChanges': function() {
var deferredResult;
var result;
Clipperz.NotificationCenter.notify(this.user(), 'updatedSection', 'records', true);
//MochiKit.Logging.logDebug(">>> Record.saveChanges");
//MochiKit.Logging.logDebug(">>> [" + (new Date()).valueOf() + "] Record.saveChanges");
if (this.headerNotes() != null) {
this.setNotes(this.headerNotes());
}
this.syncDirectLoginReferenceValues();
diff --git a/frontend/beta/js/Clipperz/PM/DataModel/User.js b/frontend/beta/js/Clipperz/PM/DataModel/User.js
index dbbe9a0..b065557 100644
--- a/frontend/beta/js/Clipperz/PM/DataModel/User.js
+++ b/frontend/beta/js/Clipperz/PM/DataModel/User.js
@@ -272,40 +272,40 @@ MochiKit.Logging.logError("- User.errorHandler: " + anErrorString + " (" + anExc
//-----------------------------------------------------------------------------
'addNewRecord': function() {
var record;
//MochiKit.Logging.logDebug(">>> User.addNewRecord");
record = new Clipperz.PM.DataModel.Record({user:this});
this.addRecord(record);
Clipperz.NotificationCenter.notify(this, 'updatedSection', 'records', true);
//MochiKit.Logging.logDebug("<<< User.addNewRecord");
return record;
},
//-------------------------------------------------------------------------
- 'saveRecords': function(someRecords, aMethodName) {
+ 'saveRecords': function(someRecords /*, aMethodName*/) {
var deferredResult;
- var methodName;
+// var methodName;
var result;
var i,c;
//console.log("User.saveRecords - someRecords", someRecords);
- methodName = aMethodName || 'addNewRecords';
+// methodName = aMethodName || 'addNewRecords';
Clipperz.NotificationCenter.notify(this, 'updatedSection', 'records', true);
//MochiKit.Logging.logDebug(">>> User.saveRecords");
//MochiKit.Logging.logDebug(">>> [" + (new Date()).valueOf() + "] User.saveRecords");
/*
MochiKit.Logging.logDebug("--- User.saveRecords - 1");
MochiKit.Iter.forEach(someRecords, function(aRecord) {
if (aRecord.headerNotes() != null) {
aRecord.setNotes(aRecord.headerNotes());
}
aRecord.syncDirectLoginReferenceValues();
aRecord.currentVersion().createNewVersion();
aRecord.updateKey();
});
MochiKit.Logging.logDebug("--- User.saveRecords - 2");
*/
@@ -354,42 +354,43 @@ MochiKit.Logging.logDebug("--- User.saveRecords - 2");
aResult['record'] = res;
return aResult;
}, recordData);
//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 6.4 " + res); return res;});
deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', {} /*'saveCard_encryptRecordVersions'*/);
//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 6.5 " + res); return res;});
deferredResult.addCallback(MochiKit.Base.method(someRecords[i].currentVersion(), 'encryptedData'));
//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 6.6 " + res); return res;});
deferredResult.addCallback(function(aResult, res) {
aResult['currentRecordVersion'] = res;
return aResult;
}, recordData);
//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 6.7 " + res); return res;});
deferredResult.addCallback(function(aResult, res) {
- aResult['records'].push(res);
+ aResult['records'] = { 'updated': [res] };
return aResult;
}, result);
//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 6.8 " + res); return res;});
}
//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 7 " + res); return res;});
deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'saveCard_sendingData');
//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 8 " + res); return res;});
- deferredResult.addCallback(MochiKit.Base.method(this.connection(), 'message'), methodName);
+// deferredResult.addCallback(MochiKit.Base.method(this.connection(), 'message'), methodName);
+ deferredResult.addCallback(MochiKit.Base.method(this.connection(), 'message'), 'saveChanges');
//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 9 " + res); return res;});
for (i=0; i<c; i++) {
//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 9.1 " + res); return res;});
deferredResult.addCallback(MochiKit.Base.method(someRecords[i], 'takeSnapshotOfCurrentData'));
//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 9.2 " + res); return res;});
deferredResult.addCallback(MochiKit.Base.method(someRecords[i], 'setIsBrandNew'), false);
//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 9.3 " + res); return res;});
}
//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 10 " + res); return res;});
deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'notify', 'recordUpdated');
//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 11 " + res); return res;});
deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'notify', 'directLoginUpdated');
//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.saveRecords - 12 " + res); return res;});
deferredResult.callback();
@@ -418,50 +419,52 @@ MochiKit.Logging.logDebug("--- User.saveRecords - 2");
parameters = {};
deferredResult = new MochiKit.Async.Deferred();
//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.deleteRecordsAction - 1 " + res); return res;});
deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'deleteRecord_collectData');
//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.deleteRecordsAction - 2 " + res); return res;});
deferredResult.addCallback(function(someParameters, someRecords) {
var recordReferences;
recordReferences = MochiKit.Base.map(function(aRecord) {
var result;
result = aRecord.reference();
aRecord.remove();
return result;
}, someRecords);
- someParameters.recordReferences = recordReferences;
+// someParameters.recordReferences = recordReferences;
+ someParameters['records'] = { 'deleted': recordReferences};
return someParameters;
}, parameters);
//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.deleteRecordsAction - 3 " + res); return res;});
deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'deleteRecord_encryptData');
//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.deleteRecordsAction - 4 " + res); return res;});
deferredResult.addCallback(MochiKit.Base.method(this, 'encryptedData'));
//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.deleteRecordsAction - 5 " + res); return res;});
deferredResult.addCallback(function(someParameters, anUserEncryptedData) {
someParameters.user = anUserEncryptedData;
return someParameters;
}, parameters);
//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.deleteRecordsAction - 6 " + res); return res;});
deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'deleteRecord_sendingData');
//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.deleteRecords parameters: " + Clipperz.Base.serializeJSON(res)); return res;});
//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.deleteRecordsAction - 7 " + res); return res;});
- deferredResult.addCallback(MochiKit.Base.method(this.connection(), 'message'), 'deleteRecords');
+// deferredResult.addCallback(MochiKit.Base.method(this.connection(), 'message'), 'deleteRecords');
+ deferredResult.addCallback(MochiKit.Base.method(this.connection(), 'message'), 'saveChanges');
//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.deleteRecordsAction - 8 " + res); return res;});
deferredResult.addCallback(Clipperz.NotificationCenter.deferredNotification, this, 'updatedProgressState', 'deleteRecord_updatingInterface');
//deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("User.deleteRecordsAction - 9 " + res); return res;});
deferredResult.callback(someRecords);
//MochiKit.Logging.logDebug("<<< User.deleteRecordsAction");
return deferredResult;
},
//-------------------------------------------------------------------------
'resetAllLocalData': function() {
this.resetConnection();
this.setUsername("");
this.setPassphrase("");