summaryrefslogtreecommitdiff
path: root/pkg/basic_auth
diff options
context:
space:
mode:
authorJulien Dessaux2024-12-28 23:16:09 +0100
committerJulien Dessaux2024-12-28 23:16:09 +0100
commit1dbb1b9ee79ec85ddb65c9b50d87903ae374c177 (patch)
tree81c70ce7c2c2aa00a4e03c0469c09d76957b6345 /pkg/basic_auth
parentfeat(tfstated): use environment variables to customize listening hostname and... (diff)
downloadtfstated-1dbb1b9ee79ec85ddb65c9b50d87903ae374c177.tar.gz
tfstated-1dbb1b9ee79ec85ddb65c9b50d87903ae374c177.tar.bz2
tfstated-1dbb1b9ee79ec85ddb65c9b50d87903ae374c177.zip
chore(tfstated): refactor setting last login date time on successful HTTP basic auth
Diffstat (limited to 'pkg/basic_auth')
-rw-r--r--pkg/basic_auth/middleware.go5
1 files changed, 1 insertions, 4 deletions
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
}