summaryrefslogtreecommitdiff
path: root/frontend/gamma/js/Clipperz/PM/Connection.js
Side-by-side diff
Diffstat (limited to 'frontend/gamma/js/Clipperz/PM/Connection.js') (more/less context) (ignore whitespace changes)
-rw-r--r--frontend/gamma/js/Clipperz/PM/Connection.js34
1 files changed, 29 insertions, 5 deletions
diff --git a/frontend/gamma/js/Clipperz/PM/Connection.js b/frontend/gamma/js/Clipperz/PM/Connection.js
index b4e8aaa..a05a310 100644
--- a/frontend/gamma/js/Clipperz/PM/Connection.js
+++ b/frontend/gamma/js/Clipperz/PM/Connection.js
@@ -42,4 +42,5 @@ Clipperz.PM.Connection = function (args) {
this._connectionId = null;
this._sharedSecret = null;
+ this._serverLockValue = null;
return this;
@@ -147,4 +148,14 @@ MochiKit.Logging.logError("### Connection.defaultErrorHandler: " + anErrorString
},
+ //-------------------------------------------------------------------------
+
+ 'serverLockValue': function () {
+ return this._serverLockValue;
+ },
+
+ 'setServerLockValue': function (aValue) {
+ this._serverLockValue = aValue;
+ },
+
//=========================================================================
/*
@@ -321,5 +332,5 @@ Clipperz.PM.Connection.SRP['1.0'].prototype = MochiKit.Base.update(new Clipperz.
},
- 'login': function(/*anUsername, aPassphrase*/) {
+ 'login': function(isReconnecting) {
var deferredResult;
var cryptoVersion;
@@ -327,5 +338,4 @@ Clipperz.PM.Connection.SRP['1.0'].prototype = MochiKit.Base.update(new Clipperz.
cryptoVersion = this.clipperz_pm_crypto_version();
-
deferredResult = new Clipperz.Async.Deferred("Connection.login", {trace:false});
deferredResult.addCallback(this.getCredentialsFunction());
@@ -400,4 +410,11 @@ Clipperz.PM.Connection.SRP['1.0'].prototype = MochiKit.Base.update(new Clipperz.
/// ?? result = this.user().oneTimePasswordManager().archiveOneTimePassword(this.oneTimePassword()));
// }
+
+ if ((isReconnecting == true) && (this.serverLockValue() != someParameters['lock'])) {
+ throw Clipperz.PM.Connection.exception.StaleData;
+ } else {
+ this.setServerLockValue(someParameters['lock']);
+ }
+
return someParameters;
}, this));
@@ -430,4 +447,10 @@ Clipperz.PM.Connection.SRP['1.0'].prototype = MochiKit.Base.update(new Clipperz.
'message': function(aMessageName, someParameters) {
var args;
+ var parameters;
+
+ parameters = someParameters || {};
+ if (typeof(parameters['user']) != 'undefined') {
+ parameters['user']['lock'] = this.serverLockValue();
+ }
//console.log(">>> Connection.message", aMessageName, someParameters);
@@ -435,5 +458,6 @@ Clipperz.PM.Connection.SRP['1.0'].prototype = MochiKit.Base.update(new Clipperz.
message: aMessageName,
srpSharedSecret: this.sharedSecret(),
- parameters: (someParameters || {})
+// parameters: (someParameters || {})
+ parameters: parameters
}
@@ -450,6 +474,5 @@ Clipperz.PM.Connection.SRP['1.0'].prototype = MochiKit.Base.update(new Clipperz.
deferredResult.addCallback(MochiKit.Base.bind(function(res) {
if (typeof(res['lock']) != 'undefined') {
-// TODO: ?????
-// ?? this.user().setLock(res['lock']);
+ this.setServerLockValue(res['lock']);
}
return res;
@@ -588,4 +611,5 @@ Clipperz.PM.Connection.SRP['1.1'].prototype = MochiKit.Base.update(new Clipperz.
Clipperz.PM.Connection.exception = {
WrongChecksum: new MochiKit.Base.NamedError("Clipperz.ByteArray.exception.InvalidValue"),
+ StaleData: new MochiKit.Base.NamedError("Stale data"),
UnexpectedRequest: new MochiKit.Base.NamedError("Clipperz.ByteArray.exception.UnexpectedRequest")
};