summaryrefslogtreecommitdiff
path: root/frontend/beta/js/Clipperz/PM/DataModel/OneTimePasswordManager.js
Unidiff
Diffstat (limited to 'frontend/beta/js/Clipperz/PM/DataModel/OneTimePasswordManager.js') (more/less context) (ignore whitespace changes)
-rw-r--r--frontend/beta/js/Clipperz/PM/DataModel/OneTimePasswordManager.js22
1 files changed, 10 insertions, 12 deletions
diff --git a/frontend/beta/js/Clipperz/PM/DataModel/OneTimePasswordManager.js b/frontend/beta/js/Clipperz/PM/DataModel/OneTimePasswordManager.js
index aa40aba..1ebb615 100644
--- a/frontend/beta/js/Clipperz/PM/DataModel/OneTimePasswordManager.js
+++ b/frontend/beta/js/Clipperz/PM/DataModel/OneTimePasswordManager.js
@@ -1,118 +1,116 @@
1/* 1/*
2 2
3Copyright 2008-2011 Clipperz Srl 3Copyright 2008-2013 Clipperz Srl
4 4
5This file is part of Clipperz Community Edition. 5This file is part of Clipperz, the online password manager.
6Clipperz Community Edition is an online password manager.
7For further information about its features and functionalities please 6For further information about its features and functionalities please
8refer to http://www.clipperz.com. 7refer to http://www.clipperz.com.
9 8
10* Clipperz Community Edition is free software: you can redistribute 9* Clipperz is free software: you can redistribute it and/or modify it
11 it and/or modify it under the terms of the GNU Affero General Public 10 under the terms of the GNU Affero General Public License as published
12 License as published by the Free Software Foundation, either version 11 by the Free Software Foundation, either version 3 of the License, or
13 3 of the License, or (at your option) any later version. 12 (at your option) any later version.
14 13
15* Clipperz Community Edition is distributed in the hope that it will 14* Clipperz is distributed in the hope that it will be useful, but
16 be useful, but WITHOUT ANY WARRANTY; without even the implied 15 WITHOUT ANY WARRANTY; without even the implied warranty of
17 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 See the GNU Affero General Public License for more details. 17 See the GNU Affero General Public License for more details.
19 18
20* You should have received a copy of the GNU Affero General Public 19* You should have received a copy of the GNU Affero General Public
21 License along with Clipperz Community Edition. If not, see 20 License along with Clipperz. If not, see http://www.gnu.org/licenses/.
22 <http://www.gnu.org/licenses/>.
23 21
24*/ 22*/
25 23
26if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } 24if (typeof(Clipperz) == 'undefined') { Clipperz = {}; }
27if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } 25if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; }
28if (typeof(Clipperz.PM.DataModel) == 'undefined') { Clipperz.PM.DataModel = {}; } 26if (typeof(Clipperz.PM.DataModel) == 'undefined') { Clipperz.PM.DataModel = {}; }
29 27
30 28
31//############################################################################# 29//#############################################################################
32 30
33Clipperz.PM.DataModel.OneTimePasswordManager = function(anUser, args) { 31Clipperz.PM.DataModel.OneTimePasswordManager = function(anUser, args) {
34 args = args || {}; 32 args = args || {};
35 33
36 this._user = anUser; 34 this._user = anUser;
37 this._oneTimePasswords = {}; 35 this._oneTimePasswords = {};
38 36
39 this.updateWithData(args); 37 this.updateWithData(args);
40 38
41 Clipperz.NotificationCenter.notify(null, 'oneTimePasswordAdded', null, true); 39 Clipperz.NotificationCenter.notify(null, 'oneTimePasswordAdded', null, true);
42 40
43 return this; 41 return this;
44} 42}
45 43
46Clipperz.PM.DataModel.OneTimePasswordManager.prototype = MochiKit.Base.update(null, { 44Clipperz.PM.DataModel.OneTimePasswordManager.prototype = MochiKit.Base.update(null, {
47 45
48 'toString': function() { 46 'toString': function() {
49 return "Clipperz.PM.DataModel.OneTimePasswordManager"; 47 return "Clipperz.PM.DataModel.OneTimePasswordManager";
50 }, 48 },
51 49
52 //------------------------------------------------------------------------- 50 //-------------------------------------------------------------------------
53 51
54 'updateWithData': function(someValues) { 52 'updateWithData': function(someValues) {
55 varotpReference; 53 varotpReference;
56 54
57//console.log("OneTimePasswordManager.updateWithData", someValues); 55//console.log("OneTimePasswordManager.updateWithData", someValues);
58//MochiKit.Logging.logDebug("OneTimePasswordManager.updateWithData: " + Clipperz.Base.serializeJSON(someValues)); 56//MochiKit.Logging.logDebug("OneTimePasswordManager.updateWithData: " + Clipperz.Base.serializeJSON(someValues));
59 for (otpReference in someValues) { 57 for (otpReference in someValues) {
60 var otp; 58 var otp;
61 var otpConfiguration; 59 var otpConfiguration;
62 60
63 otpConfiguration = someValues[otpReference]; 61 otpConfiguration = someValues[otpReference];
64 otpConfiguration['user'] = this.user(); 62 otpConfiguration['user'] = this.user();
65 otpConfiguration['reference'] = otpReference; 63 otpConfiguration['reference'] = otpReference;
66 otp = new Clipperz.PM.DataModel.OneTimePassword(otpConfiguration); 64 otp = new Clipperz.PM.DataModel.OneTimePassword(otpConfiguration);
67 this._oneTimePasswords[otpReference] = otp; 65 this._oneTimePasswords[otpReference] = otp;
68 } 66 }
69 67
70 return this; 68 return this;
71 }, 69 },
72 70
73 //------------------------------------------------------------------------- 71 //-------------------------------------------------------------------------
74 72
75 'updateWithServerData': function(someValues) { 73 'updateWithServerData': function(someValues) {
76 var deferredResult; 74 var deferredResult;
77 varoneTimePasswordReference; 75 varoneTimePasswordReference;
78 var wereChangesApplied; 76 var wereChangesApplied;
79 77
80//MochiKit.Logging.logDebug(">>> OneTimePasswordManager.updateWithServerData"); 78//MochiKit.Logging.logDebug(">>> OneTimePasswordManager.updateWithServerData");
81 deferredResult = new MochiKit.Async.Deferred(); 79 deferredResult = new MochiKit.Async.Deferred();
82 wereChangesApplied = false; 80 wereChangesApplied = false;
83 81
84 for (oneTimePasswordReference in someValues) { 82 for (oneTimePasswordReference in someValues) {
85 var oneTimePassword; 83 var oneTimePassword;
86 84
87 oneTimePassword = this.oneTimePasswordWithReference(oneTimePasswordReference); 85 oneTimePassword = this.oneTimePasswordWithReference(oneTimePasswordReference);
88 if (oneTimePassword != null) { 86 if (oneTimePassword != null) {
89 var oneTimePasswordHasBeenUpdated; 87 var oneTimePasswordHasBeenUpdated;
90 88
91 oneTimePasswordHasBeenUpdated = oneTimePassword.updateStatusWithValues(someValues[oneTimePasswordReference]); 89 oneTimePasswordHasBeenUpdated = oneTimePassword.updateStatusWithValues(someValues[oneTimePasswordReference]);
92 wereChangesApplied = oneTimePasswordHasBeenUpdated || wereChangesApplied; 90 wereChangesApplied = oneTimePasswordHasBeenUpdated || wereChangesApplied;
93 } else { 91 } else {
94 92
95 } 93 }
96 } 94 }
97 95
98 if (wereChangesApplied == true) { 96 if (wereChangesApplied == true) {
99 this.user().header().markSectionAsUpdated('oneTimePasswords'); 97 this.user().header().markSectionAsUpdated('oneTimePasswords');
100 } 98 }
101 99
102 for (oneTimePasswordReference in this.oneTimePasswords()) { 100 for (oneTimePasswordReference in this.oneTimePasswords()) {
103 if (typeof(someValues[oneTimePasswordReference]) == 'undefind') { 101 if (typeof(someValues[oneTimePasswordReference]) == 'undefind') {
104 deferredResult.addCallback(MochiKit.Base.method(this.oneTimePasswordWithReference(oneTimePasswordReference), 'saveChanges')); 102 deferredResult.addCallback(MochiKit.Base.method(this.oneTimePasswordWithReference(oneTimePasswordReference), 'saveChanges'));
105 } 103 }
106 } 104 }
107 105
108 deferredResult.addCallback(MochiKit.Async.succeed, this); 106 deferredResult.addCallback(MochiKit.Async.succeed, this);
109 107
110 deferredResult.callback(); 108 deferredResult.callback();
111//MochiKit.Logging.logDebug("<<< OneTimePasswordManager.updateWithServerData"); 109//MochiKit.Logging.logDebug("<<< OneTimePasswordManager.updateWithServerData");
112 110
113 return deferredResult; 111 return deferredResult;
114 }, 112 },
115 113
116 //------------------------------------------------------------------------- 114 //-------------------------------------------------------------------------
117 115
118 'user': function() { 116 'user': function() {