From 1dbb1b9ee79ec85ddb65c9b50d87903ae374c177 Mon Sep 17 00:00:00 2001 From: Julien Dessaux Date: Sat, 28 Dec 2024 23:16:09 +0100 Subject: chore(tfstated): refactor setting last login date time on successful HTTP basic auth --- pkg/basic_auth/middleware.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'pkg/basic_auth') diff --git a/pkg/basic_auth/middleware.go b/pkg/basic_auth/middleware.go index 0e22ad3..cb2dcf0 100644 --- a/pkg/basic_auth/middleware.go +++ b/pkg/basic_auth/middleware.go @@ -4,7 +4,6 @@ import ( "context" "fmt" "net/http" - "time" "git.adyxax.org/adyxax/tfstated/pkg/database" "git.adyxax.org/adyxax/tfstated/pkg/helpers" @@ -29,9 +28,7 @@ func Middleware(db *database.DB) func(http.Handler) http.Handler { helpers.ErrorResponse(w, http.StatusForbidden, fmt.Errorf("Forbidden")) return } - now := time.Now().UTC() - _, err = db.Exec(`UPDATE accounts SET last_login = ? WHERE id = ?`, now.Unix(), account.Id) - if err != nil { + if err := db.TouchAccount(account); err != nil { helpers.ErrorResponse(w, http.StatusInternalServerError, err) return } -- cgit v1.2.3