Use local-time:now for last-login update (database agnostic)

Replace raw PostgreSQL SQL with data-model approach using local-time:now
as suggested by easilok. This keeps the code database backend agnostic
instead of being tied to PostgreSQL-specific syntax.
This commit is contained in:
Glenn Thompson 2025-12-09 21:34:12 +03:00 committed by Brian O'Reilly
parent c1d71800ab
commit 68a83390c9
1 changed files with 4 additions and 5 deletions

View File

@ -69,12 +69,11 @@
(format t "Error during user data access: ~a~%" e))) (format t "Error during user data access: ~a~%" e)))
(when (and (= 1 user-active) (when (and (= 1 user-active)
(verify-password password user-password)) (verify-password password user-password))
;; Update last login using raw SQL to set CURRENT_TIMESTAMP ;; Update last login using data-model (database agnostic)
(handler-case (handler-case
(postmodern:with-connection (get-db-connection-params) (progn
(postmodern:execute (setf (dm:field user "last-login") (format nil "~a" (local-time:now)))
(format nil "UPDATE \"USERS\" SET \"last-login\" = CURRENT_TIMESTAMP WHERE _id = ~a" (dm:save user))
(dm:id user))))
(error (e) (error (e)
(format t "Warning: Could not update last-login: ~a~%" e))) (format t "Warning: Could not update last-login: ~a~%" e)))
user))))) user)))))