chore(tfstated): refactor setting last login date time on successful HTTP basic auth
This commit is contained in:
parent
6d00e12097
commit
1dbb1b9ee7
2 changed files with 39 additions and 32 deletions
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue