Diffstat (limited to 'frontend/beta/js/Clipperz/PM/Connection.js') (more/less context) (ignore whitespace changes)
-rw-r--r-- | frontend/beta/js/Clipperz/PM/Connection.js | 9 |
1 files changed, 7 insertions, 2 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 @@ -267,69 +267,73 @@ deferredResult.addErrback(MochiKit.Base.bind(function(res) {MochiKit.Logging.log this.srpConnection().set_s(new Clipperz.Crypto.BigInt(someParameters['s'], 16)); this.srpConnection().set_B(new Clipperz.Crypto.BigInt(someParameters['B'], 16)); if (typeof(someParameters['oneTimePassword']) != 'undefined') { this.setOneTimePassword(someParameters['oneTimePassword']); } args = {}; args.message = 'credentialCheck'; args.version = this.clipperz_pm_crypto_version(); args.parameters = {}; args.parameters['M1'] = this.srpConnection().M1(); return args; }, this)); //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("1.3.6 - Connection.login - 6: "/* + res*/); return res;}); //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;}); //deferredResult.addErrback(function(res) {MochiKit.Logging.logDebug("ERROR: " + res); return res;}); deferredResult.callback(this); //MochiKit.Logging.logDebug("<<< Connection.login"); return deferredResult; }, //========================================================================= 'logout': function() { var deferredResult; //MochiKit.Logging.logDebug(">>> Connection.logout: " + this); deferredResult = new MochiKit.Async.Deferred(); //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("Connection.logout - 1: " + res); return res;}); deferredResult.addCallback(MochiKit.Base.method(Clipperz.PM.Proxy.defaultProxy, 'logout'), {}); @@ -548,34 +552,35 @@ Clipperz.PM.Connection.SRP['1.1'].prototype = MochiKit.Base.update(new Clipperz. //----------------------------------------------------------------------------- 'C': function() { if (this._C == null) { this._C = this.hash()(new Clipperz.ByteArray(this.user().username() + this.user().passphrase())).toHexString().substring(2); } return this._C; }, //----------------------------------------------------------------------------- 'P': function() { if (this._P == null) { this._P = this.hash()(new Clipperz.ByteArray(this.user().passphrase() + this.user().username())).toHexString().substring(2); } 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") }; |