@@ -216,38 +216,37 @@ Showable {
216216 }
217217
218218 onTriggered: {
219− var now = new Date();
219+ var diff = delayTarget - new Date();
220+ if (diff > 0) {
221+ delayMinutes = Math.ceil(diff / 60000);
222+ start(); // go again
223+ } else {
224+ delayMinutes = 0;
225+ }
226+ }
227+
228+ function checkForForcedDelay() {
229+ if (greeterSettings.lockedOutTime === 0) {
230+ return;
231+ }
220232
221− // We're going to compare stored time to system time here.
222− // - We do this every tick (rather than just once at the start)
223− // because clock time can change while we're running. For example,
224− // ntpdate runs as an ifupdown script.
225− // - And we trust this check because if a malicious actor is able
226− // to manipulate time to avoid our lockout, there's not much we
227− // can do to stop them.
233+ var now = new Date();
234+ delayTarget = new Date(greeterSettings.lockedOutTime + failedLoginsDelayMinutes * 60000);
228235
229236 // If tooEarly is true, something went very wrong. Bug or NTP
230237 // misconfiguration maybe?
231238 var tooEarly = now.getTime() < greeterSettings.lockedOutTime;
232239 var tooLate = now >= delayTarget;
233240
241+ // Compare stored time to system time. If a malicious actor is
242+ // able to manipulate time to avoid our lockout, they already have
243+ // enough access to cause damage. So we choose to trust this check.
234244 if (tooEarly || tooLate) {
235245 stop();
236246 delayMinutes = 0;
237247 } else {
238− var diff = delayTarget - now;
239− delayMinutes = Math.ceil(diff / 60000);
240− start(); // go again
241− }
242− }
243−
244− function checkForForcedDelay() {
245− if (greeterSettings.lockedOutTime === 0) {
246− return;
248+ triggered();
247249 }
248−
249− delayTarget = new Date(greeterSettings.lockedOutTime + failedLoginsDelayMinutes * 60000);
250− triggered();
251250 }
252251
253252 Component.onCompleted: checkForForcedDelay()