{loginwait}

Description

Returns how many minutes a visitor has to wait before the next login attempt, when a login sent in this same request was refused for too many failed attempts. In every other case it returns an empty string - on an ordinary page view, and also on a page reached by a redirect, because only the request that carried the refused login knows about the refusal. Use it on the page a reader login form posts to (without an err_url redirect) to tell the visitor why the login did not go through and how long to wait. AA slows down logins after 5 failed attempts with one user name from one address, or 20 failed attempts with any names from one address, within 12 hours (an IPv6 address counts as its /64 network): each next attempt then waits 30 seconds (60 seconds for the address limit), twice as long after every further failure, at most 15 minutes for a name and 60 minutes for an address. Failures from other addresses never slow down a name, so nobody can lock someone else out. The value is in whole minutes, rounded up. It comes from the last check of credentials in the request: a refused check of credentials that a template passes, for example to jwtencode, counts too - so a page that checks credentials many times may show a wait although the visitor sent no login - and a later check that is let through clears it, so place loginwait before any jwtencode or setsecret on the page. The command takes no parameters and changes nothing. When the install switches this protection off, no login is refused and the result is always empty.

Examples

virtual[{loginwait}]
Expected([] - empty on a request that carried no refused login; [1] or more when one was refused)
Actual[]
On an ordinary page view no login was refused, so the result is empty - the brackets make it visible. Illustrative, not asserted: a template check of credentials refused earlier on the same page (for example jwtencode with a wrong password, repeated) sets the wait as well, and then this shows the minutes.
virtual{ifset:{loginwait}:Too many failed logins. Try again in _#1 min.:Log in below.}
Expected(Log in below. - on an ordinary view; Too many failed logins. Try again in 1 min. - in the request whose login was refused)
ActualLog in below.
The typical use on the page a reader login form posts to. On an ordinary view nothing was refused, so the else text shows. After a refused login the first text shows, with the minutes in place of _#1.
virtual{ifset:{loginwait}:Too many failed logins. Try again in _#1 min.}
Expected(Too many failed logins. Try again in 1 min. - only in the request whose login was refused; otherwise nothing)
Illustrative: the output in the request that carried a refused login, here the first 30 second wait rounded up to 1 minute. The live result on this page is empty, because no login was sent.