Merge lp:~mterry/unity8/lockout-timer into lp:unity8

Proposed by Michael Terry
Status: Merged
Approved by: Albert Astals Cid
Approved revision: 1642
Merged at revision: 1677
Proposed branch: lp:~mterry/unity8/lockout-timer
Merge into: lp:unity8
Diff against target: 112 lines (+43/-12)
2 files modified
qml/Greeter/Greeter.qml (+28/-12)
tests/qmltests/Greeter/tst_Greeter.qml (+15/-0)
To merge this branch: bzr merge lp:~mterry/unity8/lockout-timer
Reviewer Review Type Date Requested Status
Albert Astals Cid (community) Approve
PS Jenkins bot (community) continuous-integration Needs Fixing
Review via email: mp+251525@code.launchpad.net

Commit message

When we are locking the user out from too many login failures, notice when time passes even if the device is suspended. (LP: #1396817)

Description of the change

When we are locking the user out from too many login failures, notice when time passes even if the device is suspended. (LP: #1396817)

Note when testing that you have to be unplugged from USB to truly suspend the device.

== Checklist ==

 * Are there any related MPs required for this MP to build/function as expected? Please list.
 No

 * Did you perform an exploratory manual test run of your code change and any related functionality?
 Yes

 * Did you make sure that your branch does not contain spurious tags?
 Yes

 * If you changed the packaging (debian), did you subscribe the ubuntu-unity team to this MP?
 NA

 * If you changed the UI, has there been a design review?
 NA

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Albert Astals Cid (aacid) wrote :

 * Did you perform an exploratory manual test run of the code change and any related functionality?
Yes

 * Did CI run pass?
Autopilot is why not

 * Did you make sure that the branch does not contain spurious tags?
Yes

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'qml/Greeter/Greeter.qml'
2--- qml/Greeter/Greeter.qml 2015-02-23 15:43:41 +0000
3+++ qml/Greeter/Greeter.qml 2015-03-02 21:35:34 +0000
4@@ -51,7 +51,7 @@
5
6 property int maxFailedLogins: -1 // disabled by default for now, will enable via settings in future
7 property int failedLoginsDelayAttempts: 7 // number of failed logins
8- property int failedLoginsDelayMinutes: 5 // minutes of forced waiting
9+ property real failedLoginsDelayMinutes: 5 // minutes of forced waiting
10
11 signal tease()
12 signal sessionStarted()
13@@ -110,7 +110,6 @@
14
15 readonly property bool multiUser: LightDM.Users.count > 1
16 property int currentIndex
17- property int delayMinutes
18 property bool waiting
19
20 // We want 'launcherOffset' to animate down to zero. But not to animate
21@@ -185,13 +184,29 @@
22
23 Timer {
24 id: forcedDelayTimer
25- interval: 1000 * 60
26+
27+ // We use a short interval and check against the system wall clock
28+ // because we have to consider the case that the system is suspended
29+ // for a few minutes. When we wake up, we want to quickly be correct.
30+ interval: 500
31+
32+ property var delayTarget;
33+ property int delayMinutes;
34+
35+ function forceDelay(delay /* in minutes */) {
36+ delayTarget = new Date();
37+ delayTarget.setTime(delayTarget.getTime() + delay * 60000);
38+ delayMinutes = Math.ceil(delay);
39+ start();
40+ }
41+
42 onTriggered: {
43- if (d.delayMinutes > 0) {
44- d.delayMinutes -= 1;
45- if (d.delayMinutes > 0) {
46- start(); // go again
47- }
48+ var diff = delayTarget - new Date();
49+ if (diff > 0) {
50+ delayMinutes = Math.ceil(diff / 60000);
51+ start(); // go again
52+ } else {
53+ delayMinutes = 0;
54 }
55 }
56 }
57@@ -262,7 +277,7 @@
58 Binding {
59 target: loader.item
60 property: "delayMinutes"
61- value: d.delayMinutes
62+ value: forcedDelayTimer.delayMinutes
63 }
64
65 Binding {
66@@ -363,9 +378,10 @@
67 }
68
69 // Check if we should initiate a forced login delay
70- if (failedLoginsDelayAttempts > 0 && AccountsService.failedLogins % failedLoginsDelayAttempts == 0) {
71- d.delayMinutes = failedLoginsDelayMinutes;
72- forcedDelayTimer.start();
73+ if (failedLoginsDelayAttempts > 0
74+ && AccountsService.failedLogins > 0
75+ && AccountsService.failedLogins % failedLoginsDelayAttempts == 0) {
76+ forcedDelayTimer.forceDelay(failedLoginsDelayMinutes);
77 }
78
79 loader.item.notifyAuthenticationFailed();
80
81=== modified file 'tests/qmltests/Greeter/tst_Greeter.qml'
82--- tests/qmltests/Greeter/tst_Greeter.qml 2015-02-23 15:43:41 +0000
83+++ tests/qmltests/Greeter/tst_Greeter.qml 2015-03-02 21:35:34 +0000
84@@ -146,6 +146,8 @@
85 tryCompare(greeter, "waiting", false);
86 view = findChild(greeter, "testView");
87 verifySelected(LightDM.Users.data(0, LightDM.UserRoles.NameRole));
88+ greeter.failedLoginsDelayAttempts = 7;
89+ greeter.failedLoginsDelayMinutes = 5;
90 }
91
92 function cleanup() {
93@@ -429,6 +431,19 @@
94 compare(LightDM.Infographic.username, "has-password");
95 }
96
97+ function test_forcedDelay() {
98+ greeter.failedLoginsDelayAttempts = 1;
99+ greeter.failedLoginsDelayMinutes = 0.001; // make delay very short
100+
101+ selectUser("has-password");
102+ tryCompare(viewShowPromptSpy, "count", 1);
103+
104+ compare(view.delayMinutes, 0);
105+ view.responded("wr0ng p4ssw0rd");
106+ tryCompare(view, "delayMinutes", 1);
107+ tryCompare(view, "delayMinutes", 0);
108+ }
109+
110 function test_dbusRequestAuthenticationUser() {
111 selectUser("no-password");
112 LightDM.Greeter.requestAuthenticationUser("has-password");

Subscribers

People subscribed via source and target branches