on xenial help sign in
Better handle wrong password attempts
commit251731da31220d12d8d476c1694715e217f83416 authorMichael Terry <michael.terry@canonical.com> dateWed 2 Jul 2014, 14:40 (12 years ago) parenta929782
3 files changed+28−7
qml/Components/PassphraseLockscreen.qml+3 qml/Shell.qml+7−6 tests/mocks/LightDM/demo/GreeterPrivate.cpp+18−1
qml/Components/PassphraseLockscreen.qml+3
@@ -31,8 +31,10 @@ Item {
3131
3232 function clear(playAnimation) {
3333 pinentryField.text = "";
34+ pinentryField.enabled = true
3435 if (playAnimation) {
3536 wrongPasswordAnimation.start();
37+ pinentryField.forceActiveFocus();
3638 } else {
3739 pinentryField.focus = false
3840 }
@@ -78,6 +80,7 @@ Item {
7880
7981 onAccepted: {
8082 if (pinentryField.text) {
83+ pinentryField.enabled = false;
8184 root.entered(pinentryField.text);
8285 }
8386 }
qml/Shell.qml+7−6
@@ -364,7 +364,7 @@ FocusScope {
364364 onShownChanged: if (shown) greeter.fakeActiveForApp = ""
365365
366366 Component.onCompleted: {
367− if (LightDM.Users.count == 1) {
367+ if (greeter.narrowMode) {
368368 LightDM.Greeter.authenticate(LightDM.Users.data(0, LightDM.UserRoles.NameRole))
369369 }
370370 }
@@ -376,8 +376,8 @@ FocusScope {
376376 onShowGreeter: greeter.show()
377377
378378 onShowPrompt: {
379− if (LightDM.Users.count == 1) {
380− lockscreen.placeholderText = i18n.tr("Please enter %1").arg(text);
379+ if (greeter.narrowMode) {
380+ lockscreen.placeholderText = i18n.tr("Please enter %1").arg(text.toLowerCase());
381381 lockscreen.show();
382382 }
383383 }
@@ -391,6 +391,9 @@ FocusScope {
391391 greeter.login();
392392 } else {
393393 lockscreen.clear(true);
394+ if (greeter.narrowMode) {
395+ LightDM.Greeter.authenticate(LightDM.Users.data(0, LightDM.UserRoles.NameRole))
396+ }
394397 }
395398 }
396399 }
@@ -459,9 +462,7 @@ FocusScope {
459462 if (!LightDM.Greeter.promptless) {
460463 lockscreen.show();
461464 }
462− // If there is only one user, we start authenticating with that one here.
463− // If there are more users, the Greeter will handle that
464− if (LightDM.Users.count == 1) {
465+ if (greeter.narrowMode) {
465466 LightDM.Greeter.authenticate(LightDM.Users.data(0, LightDM.UserRoles.NameRole));
466467 }
467468 greeter.fakeActiveForApp = "";
tests/mocks/LightDM/demo/GreeterPrivate.cpp+18−1
@@ -54,6 +54,16 @@ public:
5454
5555 void start(QString username)
5656 {
57+ // Clear out any existing PAM interactions first (we can't simply
58+ // cancel our QFuture because QtConcurrent::run doesn't support cancel)
59+ if (pamHandle != NULL) {
60+ pam_handle *handle = pamHandle;
61+ pamHandle = NULL; // to disable normal finishPam() handling
62+ while (respond(QString())); // clear our local queue of QFutures
63+ pam_end(handle, PAM_CONV_ERR);
64+ }
65+
66+ // Now actually start a new conversation with PAM
5767 pam_conv conversation;
5868 conversation.conv = converseWithPam;
5969 conversation.appdata_ptr = static_cast<void*>(this);
@@ -158,10 +168,13 @@ public:
158168 }
159169
160170public Q_SLOTS:
161− void respond(QString response)
171+ bool respond(QString response)
162172 {
163173 if (!futures.isEmpty()) {
164174 futures.dequeue().reportFinished(&response);
175+ return true;
176+ } else {
177+ return false;
165178 }
166179 }
167180
@@ -172,6 +185,10 @@ Q_SIGNALS:
172185private Q_SLOTS:
173186 void finishPam()
174187 {
188+ if (pamHandle == NULL) {
189+ return;
190+ }
191+
175192 int pamStatus = futureWatcher.result();
176193
177194 pam_end(pamHandle, pamStatus);