mirror of
https://github.com/librecaptcha/lc-core.git
synced 2025-02-12 19:28:05 -05:00
ensure fresh captchas are served by sorting on attempted
Signed-off-by: hrj <harshad.rj@gmail.com>
This commit is contained in:
parent
7684b68efd
commit
2885decb56
@ -19,7 +19,10 @@ class Statements(dbConn: DBConn, maxAttempts: Int) {
|
|||||||
"contentInput varchar, " +
|
"contentInput varchar, " +
|
||||||
"image blob, " +
|
"image blob, " +
|
||||||
"attempted int default 0, " +
|
"attempted int default 0, " +
|
||||||
"PRIMARY KEY(token))"
|
"PRIMARY KEY(token));" +
|
||||||
|
"""
|
||||||
|
CREATE INDEX IF NOT EXISTS attempted ON challenge(attempted);
|
||||||
|
"""
|
||||||
)
|
)
|
||||||
stmt.execute(
|
stmt.execute(
|
||||||
"CREATE TABLE IF NOT EXISTS mapId" +
|
"CREATE TABLE IF NOT EXISTS mapId" +
|
||||||
@ -69,13 +72,13 @@ class Statements(dbConn: DBConn, maxAttempts: Int) {
|
|||||||
|
|
||||||
val tokenPstmt: PreparedStatement = dbConn.con.prepareStatement(
|
val tokenPstmt: PreparedStatement = dbConn.con.prepareStatement(
|
||||||
s"""
|
s"""
|
||||||
SELECT token
|
SELECT token, attempted
|
||||||
FROM challenge
|
FROM challenge
|
||||||
WHERE attempted < $maxAttempts AND
|
WHERE attempted < $maxAttempts AND
|
||||||
contentLevel = ? AND
|
contentLevel = ? AND
|
||||||
contentType = ? AND
|
contentType = ? AND
|
||||||
contentInput = ?
|
contentInput = ?
|
||||||
ORDER BY RAND() LIMIT 1"""
|
ORDER BY attempted ASC LIMIT 1"""
|
||||||
)
|
)
|
||||||
|
|
||||||
val deleteAnswerPstmt: PreparedStatement = dbConn.con.prepareStatement(
|
val deleteAnswerPstmt: PreparedStatement = dbConn.con.prepareStatement(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user