about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/LoginAttempts.hs5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/LoginAttempts.hs b/src/LoginAttempts.hs
index f5a5bde6a004..d78e12e3fd8a 100644
--- a/src/LoginAttempts.hs
+++ b/src/LoginAttempts.hs
@@ -23,7 +23,8 @@ forUsername dbFile username = withConnection dbFile $ \conn -> do
     [T.LoginAttempt{..}] -> pure (Just loginAttemptNumAttempts)
     _  -> pure Nothing
 
+-- | INSERT a failed login attempt for `username` or UPDATE an existing entry.
 increment :: FilePath -> T.Username -> IO ()
 increment dbFile username = withConnection dbFile $ \conn ->
-  execute conn "UPDATE LoginAttempts SET numAttempts = numAttempts + 1 WHERE username = ?"
-    (Only username)
+  execute conn "INSERT INTO LoginAttempts (username,numAttempts) VALUES (?,?) ON CONFLICT (username) DO UPDATE SET numAttempts = numAttempts + 1"
+    (username, 1 :: Integer)