Diffstat (limited to 'frontend/beta/js/Clipperz/PM/Components/Compact/LoginForm.js') (more/less context) (ignore whitespace changes)
-rw-r--r-- | frontend/beta/js/Clipperz/PM/Components/Compact/LoginForm.js | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/frontend/beta/js/Clipperz/PM/Components/Compact/LoginForm.js b/frontend/beta/js/Clipperz/PM/Components/Compact/LoginForm.js index a1e60d8..013dd0d 100644 --- a/frontend/beta/js/Clipperz/PM/Components/Compact/LoginForm.js +++ b/frontend/beta/js/Clipperz/PM/Components/Compact/LoginForm.js | |||
@@ -1,150 +1,148 @@ | |||
1 | /* | 1 | /* |
2 | 2 | ||
3 | Copyright 2008-2011 Clipperz Srl | 3 | Copyright 2008-2013 Clipperz Srl |
4 | 4 | ||
5 | This file is part of Clipperz Community Edition. | 5 | This file is part of Clipperz, the online password manager. |
6 | Clipperz Community Edition is an online password manager. | ||
7 | For further information about its features and functionalities please | 6 | For further information about its features and functionalities please |
8 | refer to http://www.clipperz.com. | 7 | refer 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 | ||
26 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } | 24 | if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } |
27 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } | 25 | if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } |
28 | if (typeof(Clipperz.PM.Components) == 'undefined') { Clipperz.PM.Components = {}; } | 26 | if (typeof(Clipperz.PM.Components) == 'undefined') { Clipperz.PM.Components = {}; } |
29 | if (typeof(Clipperz.PM.Components.Compact) == 'undefined') { Clipperz.PM.Components.Compact = {}; } | 27 | if (typeof(Clipperz.PM.Components.Compact) == 'undefined') { Clipperz.PM.Components.Compact = {}; } |
30 | 28 | ||
31 | Clipperz.PM.Components.Compact.LoginForm = function(anElement, args) { | 29 | Clipperz.PM.Components.Compact.LoginForm = function(anElement, args) { |
32 | 30 | ||
33 | Clipperz.PM.Components.Compact.LoginForm.superclass.constructor.call(this, anElement, args); | 31 | Clipperz.PM.Components.Compact.LoginForm.superclass.constructor.call(this, anElement, args); |
34 | 32 | ||
35 | this.render(); | 33 | this.render(); |
36 | Clipperz.NotificationCenter.register(null, 'updatedProgressState', this, 'userNotificationHandler') | 34 | Clipperz.NotificationCenter.register(null, 'updatedProgressState', this, 'userNotificationHandler') |
37 | 35 | ||
38 | return this; | 36 | return this; |
39 | }; | 37 | }; |
40 | 38 | ||
41 | YAHOO.extendX(Clipperz.PM.Components.Compact.LoginForm, Clipperz.PM.Components.BaseComponent, { | 39 | YAHOO.extendX(Clipperz.PM.Components.Compact.LoginForm, Clipperz.PM.Components.BaseComponent, { |
42 | 40 | ||
43 | 'toString': function() { | 41 | 'toString': function() { |
44 | return "Clipperz.PM.Components.Compact.LoginForm"; | 42 | return "Clipperz.PM.Components.Compact.LoginForm"; |
45 | }, | 43 | }, |
46 | 44 | ||
47 | //----------------------------------------------------- | 45 | //----------------------------------------------------- |
48 | 46 | ||
49 | 'render': function() { | 47 | 'render': function() { |
50 | var result; | 48 | var result; |
51 | varlayout; | 49 | varlayout; |
52 | 50 | ||
53 | MochiKit.Signal.disconnectAllTo(this); | 51 | MochiKit.Signal.disconnectAllTo(this); |
54 | this.element().update(""); | 52 | this.element().update(""); |
55 | 53 | ||
56 | Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'div', id:this.getId('baseDiv'), cls:'LoginPanel', children:[ | 54 | Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'div', id:this.getId('baseDiv'), cls:'LoginPanel', children:[ |
57 | {tag:'div', id:'compactHeader'}, | 55 | {tag:'div', id:'compactHeader'}, |
58 | {tag:'div', id:'compactBody', children:[ | 56 | {tag:'div', id:'compactBody', children:[ |
59 | {tag:'form', id:this.getId('loginForm_form'), children:[ | 57 | {tag:'form', id:this.getId('loginForm_form'), children:[ |
60 | {tag:'dl', children:[ | 58 | {tag:'dl', children:[ |
61 | {tag:'dt', htmlString:Clipperz.PM.Strings['loginFormUsernameLabel']}, | 59 | {tag:'dt', htmlString:Clipperz.PM.Strings['loginFormUsernameLabel']}, |
62 | {tag:'dd', children:[ | 60 | {tag:'dd', children:[ |
63 | {tag:'input', id:this.getId('login_username'), type:'text', size:'30', name:'username'} | 61 | {tag:'input', id:this.getId('login_username'), type:'text', size:'30', name:'username'} |
64 | ]}, | 62 | ]}, |
65 | {tag:'dt', htmlString:Clipperz.PM.Strings['loginFormPassphraseLabel']}, | 63 | {tag:'dt', htmlString:Clipperz.PM.Strings['loginFormPassphraseLabel']}, |
66 | {tag:'dd', children:[ | 64 | {tag:'dd', children:[ |
67 | {tag:'input', id:this.getId('login_passphrase'), type:'password', size:'30', name:'passphrase'} | 65 | {tag:'input', id:this.getId('login_passphrase'), type:'password', size:'30', name:'passphrase'} |
68 | ]} | 66 | ]} |
69 | ]}, | 67 | ]}, |
70 | {tag:'div', id:this.getId('login_submit')} | 68 | {tag:'div', id:this.getId('login_submit')} |
71 | ]}, | 69 | ]}, |
72 | {tag:'h4', id:this.getId('message')} | 70 | {tag:'h4', id:this.getId('message')} |
73 | ]} | 71 | ]} |
74 | ]}); | 72 | ]}); |
75 | 73 | ||
76 | new Clipperz.PM.Components.Compact.CompactHeader(YAHOO.ext.Element.get('compactHeader')); | 74 | new Clipperz.PM.Components.Compact.CompactHeader(YAHOO.ext.Element.get('compactHeader')); |
77 | 75 | ||
78 | MochiKit.Signal.connect(this.getId('loginForm_form'), 'onsubmit', this, 'stopFormSubmit'); | 76 | MochiKit.Signal.connect(this.getId('loginForm_form'), 'onsubmit', this, 'stopFormSubmit'); |
79 | new YAHOO.ext.Button(this.getId('login_submit'), {text:Clipperz.PM.Strings['loginFormButtonLabel'], handler:this.doLogin, scope:this, minWidth:0}); | 77 | new YAHOO.ext.Button(this.getId('login_submit'), {text:Clipperz.PM.Strings['loginFormButtonLabel'], handler:this.doLogin, scope:this, minWidth:0}); |
80 | this.getElement('login_submit').swallowEvent('click', true); | 78 | this.getElement('login_submit').swallowEvent('click', true); |
81 | 79 | ||
82 | MochiKit.Signal.connect(this.getId('loginForm_form'), 'onkeydown', this, 'onkeydown'); | 80 | MochiKit.Signal.connect(this.getId('loginForm_form'), 'onkeydown', this, 'onkeydown'); |
83 | 81 | ||
84 | new Clipperz.PM.Components.PasswordEntropyDisplay(this.getElement('login_passphrase')); | 82 | new Clipperz.PM.Components.PasswordEntropyDisplay(this.getElement('login_passphrase')); |
85 | this.getElement('login_username').focus(); | 83 | this.getElement('login_username').focus(); |
86 | 84 | ||
87 | return result; | 85 | return result; |
88 | }, | 86 | }, |
89 | 87 | ||
90 | //----------------------------------------------------- | 88 | //----------------------------------------------------- |
91 | 89 | ||
92 | 'doLogin': function(e) { | 90 | 'doLogin': function(e) { |
93 | //MochiKit.Logging.logDebug(">>> compact.LoginForm.doLogin"); | 91 | //MochiKit.Logging.logDebug(">>> compact.LoginForm.doLogin"); |
94 | if (this.checkLoginForm()) { | 92 | if (this.checkLoginForm()) { |
95 | this.doLoginWithUsernameAndPassphrase(this.getDom('login_username').value, this.getDom('login_passphrase').value); | 93 | this.doLoginWithUsernameAndPassphrase(this.getDom('login_username').value, this.getDom('login_passphrase').value); |
96 | } | 94 | } |
97 | //MochiKit.Logging.logDebug("<<< compact.LoginForm.doLogin"); | 95 | //MochiKit.Logging.logDebug("<<< compact.LoginForm.doLogin"); |
98 | }, | 96 | }, |
99 | 97 | ||
100 | //......................................................................... | 98 | //......................................................................... |
101 | 99 | ||
102 | 'doLoginWithUsernameAndPassphrase': function(anUsername, aPassphrase) { | 100 | 'doLoginWithUsernameAndPassphrase': function(anUsername, aPassphrase) { |
103 | var deferredResult; | 101 | var deferredResult; |
104 | var user; | 102 | var user; |
105 | 103 | ||
106 | //MochiKit.Logging.logDebug(">>> compact.LoginForm.doLoginWithUsernameAndPassphrase"); | 104 | //MochiKit.Logging.logDebug(">>> compact.LoginForm.doLoginWithUsernameAndPassphrase"); |
107 | user = new Clipperz.PM.DataModel.User({username:anUsername, passphrase:aPassphrase}); | 105 | user = new Clipperz.PM.DataModel.User({username:anUsername, passphrase:aPassphrase}); |
108 | 106 | ||
109 | deferredResult = new MochiKit.Async.Deferred(); | 107 | deferredResult = new MochiKit.Async.Deferred(); |
110 | deferredResult.addCallback(MochiKit.Base.method(user, 'connect')); | 108 | deferredResult.addCallback(MochiKit.Base.method(user, 'connect')); |
111 | deferredResult.addCallback(MochiKit.Base.method(user, 'loadPreferences')); | 109 | deferredResult.addCallback(MochiKit.Base.method(user, 'loadPreferences')); |
112 | deferredResult.addCallback(MochiKit.Base.method(user, 'loadRecords')); | 110 | deferredResult.addCallback(MochiKit.Base.method(user, 'loadRecords')); |
113 | deferredResult.addCallback(MochiKit.Base.method(user, 'loadDirectLogins')); | 111 | deferredResult.addCallback(MochiKit.Base.method(user, 'loadDirectLogins')); |
114 | deferredResult.addErrback(MochiKit.Base.bind(function() { | 112 | deferredResult.addErrback(MochiKit.Base.bind(function() { |
115 | this.getElement('loginForm_form').setVisibilityMode(YAHOO.ext.Element.DISPLAY).show(); | 113 | this.getElement('loginForm_form').setVisibilityMode(YAHOO.ext.Element.DISPLAY).show(); |
116 | this.getElement('message').update(Clipperz.PM.Strings['loginMessagePanelFailureText']); | 114 | this.getElement('message').update(Clipperz.PM.Strings['loginMessagePanelFailureText']); |
117 | this.getDom('login_passphrase').value = ""; | 115 | this.getDom('login_passphrase').value = ""; |
118 | this.getElement('login_passphrase').focus(); | 116 | this.getElement('login_passphrase').focus(); |
119 | }, this)) | 117 | }, this)) |
120 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("compact.LoginForm.doLogin - 6: " + res); return res;}); | 118 | //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("compact.LoginForm.doLogin - 6: " + res); return res;}); |
121 | deferredResult.callback("token"); | 119 | deferredResult.callback("token"); |
122 | //MochiKit.Logging.logDebug("<<< compact.LoginForm.doLoginWithUsernameAndPassphrase"); | 120 | //MochiKit.Logging.logDebug("<<< compact.LoginForm.doLoginWithUsernameAndPassphrase"); |
123 | 121 | ||
124 | return deferredResult; | 122 | return deferredResult; |
125 | }, | 123 | }, |
126 | 124 | ||
127 | //......................................................................... | 125 | //......................................................................... |
128 | 126 | ||
129 | 'checkLoginForm': function() { | 127 | 'checkLoginForm': function() { |
130 | var result; | 128 | var result; |
131 | var username | 129 | var username |
132 | varpassphrase; | 130 | varpassphrase; |
133 | 131 | ||
134 | //MochiKit.Logging.logDebug(">>> checkLoginForm"); | 132 | //MochiKit.Logging.logDebug(">>> checkLoginForm"); |
135 | username = this.getDom('login_username').value; | 133 | username = this.getDom('login_username').value; |
136 | passphrase = this.getDom('login_passphrase').value; | 134 | passphrase = this.getDom('login_passphrase').value; |
137 | 135 | ||
138 | if ((username != "") && (passphrase != "")) { | 136 | if ((username != "") && (passphrase != "")) { |
139 | result = true; | 137 | result = true; |
140 | } else { | 138 | } else { |
141 | if (username == "") { | 139 | if (username == "") { |
142 | this.getElement('login_username').focus(); | 140 | this.getElement('login_username').focus(); |
143 | } else if (passphrase == "") { | 141 | } else if (passphrase == "") { |
144 | this.getElement('login_passphrase').focus(); | 142 | this.getElement('login_passphrase').focus(); |
145 | } | 143 | } |
146 | 144 | ||
147 | result = false; | 145 | result = false; |
148 | } | 146 | } |
149 | //MochiKit.Logging.logDebug("<<< checkLoginForm - " + result); | 147 | //MochiKit.Logging.logDebug("<<< checkLoginForm - " + result); |
150 | 148 | ||