author | Clipperz <info@clipperz.com> | 2013-01-08 15:21:04 (UTC) |
---|---|---|
committer | Clipperz <info@clipperz.com> | 2013-01-08 15:21:04 (UTC) |
commit | 816fc35420a434b1d54ae5833d617608f7456048 (patch) (unidiff) | |
tree | 95b8caf354083593d7775e4dda6f4c556b44a2d9 /frontend/gamma/js/Clipperz/PM/DataModel/User.js | |
parent | 267603e3aa3cf0029411e67ae14018b52344c296 (diff) | |
download | clipperz-816fc35420a434b1d54ae5833d617608f7456048.zip clipperz-816fc35420a434b1d54ae5833d617608f7456048.tar.gz clipperz-816fc35420a434b1d54ae5833d617608f7456048.tar.bz2 |
Updated version of /gamma
Tons of changes, included a new draft of the mobile version (still VERY rough)
Diffstat (limited to 'frontend/gamma/js/Clipperz/PM/DataModel/User.js') (more/less context) (ignore whitespace changes)
-rw-r--r-- | frontend/gamma/js/Clipperz/PM/DataModel/User.js | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/frontend/gamma/js/Clipperz/PM/DataModel/User.js b/frontend/gamma/js/Clipperz/PM/DataModel/User.js index 72d4006..646ce21 100644 --- a/frontend/gamma/js/Clipperz/PM/DataModel/User.js +++ b/frontend/gamma/js/Clipperz/PM/DataModel/User.js | |||
@@ -35,25 +35,25 @@ Clipperz.PM.DataModel.User = function (args) { | |||
35 | 35 | ||
36 | Clipperz.PM.DataModel.User.superclass.constructor.apply(this, arguments); | 36 | Clipperz.PM.DataModel.User.superclass.constructor.apply(this, arguments); |
37 | 37 | ||
38 | this._username = args.username || null; | 38 | this._username = args.username || null; |
39 | this._getPassphraseFunction = args.getPassphraseFunction || null; | 39 | this._getPassphraseFunction = args.getPassphraseFunction || null; |
40 | 40 | ||
41 | this._data = null; | 41 | this._data = null; |
42 | 42 | ||
43 | this._connection = null; | 43 | this._connection = null; |
44 | this._connectionVersion = 'current'; | 44 | this._connectionVersion = 'current'; |
45 | 45 | ||
46 | this._serverData = null; | 46 | this._serverData = null; |
47 | this._serverLockValue = null; | 47 | //this._serverLockValue = null; |
48 | this._transientState = null; | 48 | this._transientState = null; |
49 | 49 | ||
50 | this._deferredLocks = { | 50 | this._deferredLocks = { |
51 | 'passphrase': new MochiKit.Async.DeferredLock(), | 51 | 'passphrase': new MochiKit.Async.DeferredLock(), |
52 | 'serverData': new MochiKit.Async.DeferredLock(), | 52 | 'serverData': new MochiKit.Async.DeferredLock(), |
53 | // 'recordsIndex': new MochiKit.Async.DeferredLock(), | 53 | // 'recordsIndex': new MochiKit.Async.DeferredLock(), |
54 | // 'directLoginsIndex':new MochiKit.Async.DeferredLock() | 54 | // 'directLoginsIndex':new MochiKit.Async.DeferredLock() |
55 | // 'preferences': new MochiKit.Async.DeferredLock() | 55 | // 'preferences': new MochiKit.Async.DeferredLock() |
56 | // 'oneTimePasswords': new MochiKit.Async.DeferredLock() | 56 | // 'oneTimePasswords': new MochiKit.Async.DeferredLock() |
57 | '__syntaxFix__': 'syntax fix' | 57 | '__syntaxFix__': 'syntax fix' |
58 | }; | 58 | }; |
59 | 59 | ||
@@ -84,33 +84,33 @@ Clipperz.Base.extend(Clipperz.PM.DataModel.User, Object, { | |||
84 | 84 | ||
85 | //------------------------------------------------------------------------- | 85 | //------------------------------------------------------------------------- |
86 | 86 | ||
87 | 'data': function () { | 87 | 'data': function () { |
88 | if (this._data == null) { | 88 | if (this._data == null) { |
89 | this._data = new Clipperz.KeyValueObjectStore(/*{'name':'User.data [1]'}*/); | 89 | this._data = new Clipperz.KeyValueObjectStore(/*{'name':'User.data [1]'}*/); |
90 | }; | 90 | }; |
91 | 91 | ||
92 | return this._data; | 92 | return this._data; |
93 | }, | 93 | }, |
94 | 94 | ||
95 | //------------------------------------------------------------------------- | 95 | //------------------------------------------------------------------------- |
96 | 96 | /* | |
97 | 'serverLockValue': function () { | 97 | 'serverLockValue': function () { |
98 | return this._serverLockValue; | 98 | return this._serverLockValue; |
99 | }, | 99 | }, |
100 | 100 | ||
101 | 'setServerLockValue': function (aValue) { | 101 | 'setServerLockValue': function (aValue) { |
102 | this._serverLockValue = aValue; | 102 | this._serverLockValue = aValue; |
103 | }, | 103 | }, |
104 | 104 | */ | |
105 | //------------------------------------------------------------------------- | 105 | //------------------------------------------------------------------------- |
106 | 106 | ||
107 | 'transientState': function () { | 107 | 'transientState': function () { |
108 | if (this._transientState == null) { | 108 | if (this._transientState == null) { |
109 | this._transientState = {} | 109 | this._transientState = {} |
110 | } | 110 | } |
111 | 111 | ||
112 | return this._transientState; | 112 | return this._transientState; |
113 | }, | 113 | }, |
114 | 114 | ||
115 | 'resetTransientState': function (isCommitting) { | 115 | 'resetTransientState': function (isCommitting) { |
116 | this._transientState = null; | 116 | this._transientState = null; |
@@ -211,26 +211,26 @@ Clipperz.Base.extend(Clipperz.PM.DataModel.User, Object, { | |||
211 | //......................................................................... | 211 | //......................................................................... |
212 | 212 | ||
213 | 'registerAsNewAccount': function () { | 213 | 'registerAsNewAccount': function () { |
214 | var deferredResult; | 214 | var deferredResult; |
215 | 215 | ||
216 | deferredResult = new Clipperz.Async.Deferred("User.registerAsNewAccount", {trace:false}); | 216 | deferredResult = new Clipperz.Async.Deferred("User.registerAsNewAccount", {trace:false}); |
217 | deferredResult.addCallbackPass(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'updateProgress', {'extraSteps':3}); | 217 | deferredResult.addCallbackPass(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'updateProgress', {'extraSteps':3}); |
218 | deferredResult.addMethod(this, 'initialSetupWithNoData') | 218 | deferredResult.addMethod(this, 'initialSetupWithNoData') |
219 | deferredResult.addMethod(this, 'getPassphrase'); | 219 | deferredResult.addMethod(this, 'getPassphrase'); |
220 | deferredResult.addMethod(this, 'prepareRemoteDataWithKey'); | 220 | deferredResult.addMethod(this, 'prepareRemoteDataWithKey'); |
221 | deferredResult.addCallbackPass(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'advanceProgress'); | 221 | deferredResult.addCallbackPass(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'advanceProgress'); |
222 | deferredResult.addMethod(this.connection(), 'register'); | 222 | deferredResult.addMethod(this.connection(), 'register'); |
223 | deferredResult.addCallback(MochiKit.Base.itemgetter('lock')); | 223 | // deferredResult.addCallback(MochiKit.Base.itemgetter('lock')); |
224 | deferredResult.addMethod(this, 'setServerLockValue'); | 224 | // deferredResult.addMethod(this, 'setServerLockValue'); |
225 | deferredResult.addCallbackPass(MochiKit.Signal.signal,Clipperz.Signal.NotificationCenter, 'userSuccessfullyRegistered'); | 225 | deferredResult.addCallbackPass(MochiKit.Signal.signal,Clipperz.Signal.NotificationCenter, 'userSuccessfullyRegistered'); |
226 | 226 | ||
227 | // deferredResult.addErrback (MochiKit.Base.method(this, 'handleRegistrationFailure')); | 227 | // deferredResult.addErrback (MochiKit.Base.method(this, 'handleRegistrationFailure')); |
228 | 228 | ||
229 | deferredResult.callback(); | 229 | deferredResult.callback(); |
230 | 230 | ||
231 | return deferredResult; | 231 | return deferredResult; |
232 | }, | 232 | }, |
233 | 233 | ||
234 | //------------------------------------------------------------------------- | 234 | //------------------------------------------------------------------------- |
235 | 235 | ||
236 | 'login': function () { | 236 | 'login': function () { |
@@ -238,25 +238,25 @@ Clipperz.Base.extend(Clipperz.PM.DataModel.User, Object, { | |||
238 | 238 | ||
239 | deferredResult = new Clipperz.Async.Deferred("User.login", {trace:false}); | 239 | deferredResult = new Clipperz.Async.Deferred("User.login", {trace:false}); |
240 | deferredResult.addCallbackPass(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'updateProgress', {'extraSteps':3}); | 240 | deferredResult.addCallbackPass(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'updateProgress', {'extraSteps':3}); |
241 | deferredResult.addMethod(this, 'getPassphrase'); | 241 | deferredResult.addMethod(this, 'getPassphrase'); |
242 | deferredResult.addCallback(Clipperz.PM.DataModel.OneTimePassword.isValidOneTimePasswordValue); | 242 | deferredResult.addCallback(Clipperz.PM.DataModel.OneTimePassword.isValidOneTimePasswordValue); |
243 | deferredResult.addCallback(Clipperz.Async.deferredIf("Is the passphrase an OTP", [ | 243 | deferredResult.addCallback(Clipperz.Async.deferredIf("Is the passphrase an OTP", [ |
244 | MochiKit.Base.partial(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'updateProgress', {'extraSteps':1}), | 244 | MochiKit.Base.partial(MochiKit.Signal.signal, Clipperz.Signal.NotificationCenter, 'updateProgress', {'extraSteps':1}), |
245 | MochiKit.Base.method(this, 'getCredentials'), | 245 | MochiKit.Base.method(this, 'getCredentials'), |
246 | MochiKit.Base.method(this.connection(), 'redeemOneTimePassword'), | 246 | MochiKit.Base.method(this.connection(), 'redeemOneTimePassword'), |
247 | MochiKit.Base.method(this.data(), 'setValue', 'passphrase') | 247 | MochiKit.Base.method(this.data(), 'setValue', 'passphrase') |
248 | ], [])); | 248 | ], [])); |
249 | deferredResult.addErrback(MochiKit.Base.method(this, 'getPassphrase')); | 249 | deferredResult.addErrback(MochiKit.Base.method(this, 'getPassphrase')); |
250 | deferredResult.addMethod(this.connection(), 'login'); | 250 | deferredResult.addMethod(this.connection(), 'login', false); |
251 | deferredResult.addCallbackPass(MochiKit.Signal.signal,Clipperz.Signal.NotificationCenter, 'userSuccessfullyLoggedIn'); | 251 | deferredResult.addCallbackPass(MochiKit.Signal.signal,Clipperz.Signal.NotificationCenter, 'userSuccessfullyLoggedIn'); |
252 | deferredResult.addErrback (MochiKit.Base.method(this, 'handleConnectionFallback')); | 252 | deferredResult.addErrback (MochiKit.Base.method(this, 'handleConnectionFallback')); |
253 | 253 | ||
254 | deferredResult.callback(); | 254 | deferredResult.callback(); |
255 | 255 | ||
256 | return deferredResult; | 256 | return deferredResult; |
257 | }, | 257 | }, |
258 | 258 | ||
259 | //......................................................................... | 259 | //......................................................................... |
260 | 260 | ||
261 | 'handleConnectionFallback': function(aValue) { | 261 | 'handleConnectionFallback': function(aValue) { |
262 | var result; | 262 | var result; |
@@ -320,25 +320,25 @@ Clipperz.Base.extend(Clipperz.PM.DataModel.User, Object, { | |||
320 | 320 | ||
321 | //------------------------------------------------------------------------- | 321 | //------------------------------------------------------------------------- |
322 | 322 | ||
323 | 'unpackServerData': function (someServerData) { | 323 | 'unpackServerData': function (someServerData) { |
324 | var unpackedData; | 324 | var unpackedData; |
325 | var headerVersion; | 325 | var headerVersion; |
326 | 326 | ||
327 | varrecordsIndex; | 327 | varrecordsIndex; |
328 | var preferences; | 328 | var preferences; |
329 | var oneTimePasswords; | 329 | var oneTimePasswords; |
330 | 330 | ||
331 | //console.log(">>> ***************** user.unpackServerData", someServerData); | 331 | //console.log(">>> ***************** user.unpackServerData", someServerData); |
332 | this.setServerLockValue(someServerData['lock']); | 332 | // this.setServerLockValue(someServerData['lock']); |
333 | 333 | ||
334 | headerVersion = this.headerFormatVersion(someServerData['header']); | 334 | headerVersion = this.headerFormatVersion(someServerData['header']); |
335 | 335 | ||
336 | switch (headerVersion) { | 336 | switch (headerVersion) { |
337 | case 'LEGACY': | 337 | case 'LEGACY': |
338 | varlegacyHeader; | 338 | varlegacyHeader; |
339 | 339 | ||
340 | legacyHeader = new Clipperz.PM.DataModel.User.Header.Legacy({ | 340 | legacyHeader = new Clipperz.PM.DataModel.User.Header.Legacy({ |
341 | 'retrieveKeyFunction': MochiKit.Base.method(this, 'getPassphrase'), | 341 | 'retrieveKeyFunction': MochiKit.Base.method(this, 'getPassphrase'), |
342 | 'remoteData': { | 342 | 'remoteData': { |
343 | 'data': someServerData['header'], | 343 | 'data': someServerData['header'], |
344 | 'version': someServerData['version'], | 344 | 'version': someServerData['version'], |
@@ -653,26 +653,26 @@ Clipperz.Base.extend(Clipperz.PM.DataModel.User, Object, { | |||
653 | 653 | ||
654 | return deferredResult; | 654 | return deferredResult; |
655 | }, | 655 | }, |
656 | 656 | ||
657 | //========================================================================= | 657 | //========================================================================= |
658 | 658 | ||
659 | 'commitTransientState': function () { | 659 | 'commitTransientState': function () { |
660 | return Clipperz.Async.callbacks("User.commitTransientState", [ | 660 | return Clipperz.Async.callbacks("User.commitTransientState", [ |
661 | MochiKit.Base.method(this, 'invokeMethodNamedOnHeader', 'commitTransientState'), | 661 | MochiKit.Base.method(this, 'invokeMethodNamedOnHeader', 'commitTransientState'), |
662 | MochiKit.Base.method(this, 'invokeMethodNamedOnRecords', 'commitTransientState'), | 662 | MochiKit.Base.method(this, 'invokeMethodNamedOnRecords', 'commitTransientState'), |
663 | 663 | ||
664 | MochiKit.Base.method(this, 'transientState'), | 664 | MochiKit.Base.method(this, 'transientState'), |
665 | MochiKit.Base.itemgetter('lock'), | 665 | // MochiKit.Base.itemgetter('lock'), |
666 | MochiKit.Base.method(this, 'setServerLockValue'), | 666 | // MochiKit.Base.method(this, 'setServerLockValue'), |
667 | MochiKit.Base.method(this, 'resetTransientState', true) | 667 | MochiKit.Base.method(this, 'resetTransientState', true) |
668 | ], {trace:false}); | 668 | ], {trace:false}); |
669 | }, | 669 | }, |
670 | 670 | ||
671 | //------------------------------------------------------------------------- | 671 | //------------------------------------------------------------------------- |
672 | 672 | ||
673 | 'revertChanges': function () { | 673 | 'revertChanges': function () { |
674 | return Clipperz.Async.callbacks("User.revertChanges", [ | 674 | return Clipperz.Async.callbacks("User.revertChanges", [ |
675 | MochiKit.Base.method(this, 'invokeMethodNamedOnHeader', 'revertChanges'), | 675 | MochiKit.Base.method(this, 'invokeMethodNamedOnHeader', 'revertChanges'), |
676 | MochiKit.Base.method(this, 'invokeMethodNamedOnRecords', 'revertChanges'), | 676 | MochiKit.Base.method(this, 'invokeMethodNamedOnRecords', 'revertChanges'), |
677 | MochiKit.Base.method(this, 'resetTransientState', false) | 677 | MochiKit.Base.method(this, 'resetTransientState', false) |
678 | ], {trace:false}); | 678 | ], {trace:false}); |
@@ -731,25 +731,25 @@ Clipperz.Base.extend(Clipperz.PM.DataModel.User, Object, { | |||
731 | header['records'] = someHeaderPackedData['recordIndex']['records']; | 731 | header['records'] = someHeaderPackedData['recordIndex']['records']; |
732 | header['directLogins'] = someHeaderPackedData['recordIndex']['directLogins']; | 732 | header['directLogins'] = someHeaderPackedData['recordIndex']['directLogins']; |
733 | header['preferences'] = {'data': someHeaderPackedData['preferences']['data']}; // this._serverData['header']['preferences']; // Clipperz.Base.evalJSON(this._serverData['header']['data'])['preferences']; //??????????? | 733 | header['preferences'] = {'data': someHeaderPackedData['preferences']['data']}; // this._serverData['header']['preferences']; // Clipperz.Base.evalJSON(this._serverData['header']['data'])['preferences']; //??????????? |
734 | header['oneTimePasswords'] = {'data': someHeaderPackedData['oneTimePasswords']['data']}; // this._serverData['header']['oneTimePasswords']; // Clipperz.Base.evalJSON(this._serverData['header']['data'])['oneTimePasswords']; //??????????? | 734 | header['oneTimePasswords'] = {'data': someHeaderPackedData['oneTimePasswords']['data']}; // this._serverData['header']['oneTimePasswords']; // Clipperz.Base.evalJSON(this._serverData['header']['data'])['oneTimePasswords']; //??????????? |
735 | header['version'] = '0.1'; | 735 | header['version'] = '0.1'; |
736 | 736 | ||
737 | aResult['header'] = Clipperz.Base.serializeJSON(header); | 737 | aResult['header'] = Clipperz.Base.serializeJSON(header); |
738 | aResult['statistics'] = this._serverData['statistics']; //"someHeaderPackedData['statistics']['data']"; | 738 | aResult['statistics'] = this._serverData['statistics']; //"someHeaderPackedData['statistics']['data']"; |
739 | 739 | ||
740 | return aResult; | 740 | return aResult; |
741 | }, this), result); | 741 | }, this), result); |
742 | deferredResult.addCallback(Clipperz.Async.setItem, result, 'version', Clipperz.PM.Crypto.encryptingFunctions.currentVersion); | 742 | deferredResult.addCallback(Clipperz.Async.setItem, result, 'version', Clipperz.PM.Crypto.encryptingFunctions.currentVersion); |
743 | deferredResult.addCallback(Clipperz.Async.setItem, result, 'lock', this.serverLockValue()); | 743 | // deferredResult.addCallback(Clipperz.Async.setItem, result, 'lock', this.serverLockValue()); |
744 | deferredResult.callback(); | 744 | deferredResult.callback(); |
745 | 745 | ||
746 | return deferredResult; | 746 | return deferredResult; |
747 | }, | 747 | }, |
748 | 748 | ||
749 | //========================================================================= | 749 | //========================================================================= |
750 | 750 | ||
751 | 'saveChanges': function () { | 751 | 'saveChanges': function () { |
752 | vardeferredResult; | 752 | vardeferredResult; |
753 | var messageParameters; | 753 | var messageParameters; |
754 | 754 | ||
755 | messageParameters = {}; | 755 | messageParameters = {}; |