Add token ID to request log data

This commit is contained in:
Jacob Gunther
2024-06-14 10:50:27 -05:00
parent a7c9a7df72
commit c7a9bc87e4
2 changed files with 9 additions and 8 deletions

View File

@@ -31,7 +31,7 @@ type Application struct {
ShortDescription string `bson:"shortDescription" json:"shortDescription"` ShortDescription string `bson:"shortDescription" json:"shortDescription"`
User string `bson:"user" json:"user"` User string `bson:"user" json:"user"`
Token string `bson:"token" json:"token"` Token string `bson:"token" json:"token"`
TotalRequests uint64 `bson:"totalRequests" json:"totalRequests"` RequestCount uint64 `bson:"requestCount" json:"requestCount"`
CreatedAt time.Time `bson:"createdAt" json:"createdAt"` CreatedAt time.Time `bson:"createdAt" json:"createdAt"`
} }
@@ -39,7 +39,7 @@ type Token struct {
ID string `bson:"_id" json:"id"` ID string `bson:"_id" json:"id"`
Name string `bson:"name" json:"name"` Name string `bson:"name" json:"name"`
Token string `bson:"token" json:"token"` Token string `bson:"token" json:"token"`
TotalRequests uint64 `bson:"totalRequests" json:"totalRequests"` RequestCount uint64 `bson:"requestCount" json:"requestCount"`
Application string `bson:"application" json:"application"` Application string `bson:"application" json:"application"`
CreatedAt time.Time `bson:"createdAt" json:"createdAt"` CreatedAt time.Time `bson:"createdAt" json:"createdAt"`
LastUsedAt time.Time `bson:"lastUsedAt" json:"lastUsedAt"` LastUsedAt time.Time `bson:"lastUsedAt" json:"lastUsedAt"`

View File

@@ -330,6 +330,7 @@ func Authenticate(ctx *fiber.Ctx) (bool, error) {
bson.M{ bson.M{
"application": token.Application, "application": token.Application,
"timestamp": GetStartOfHour(), "timestamp": GetStartOfHour(),
"token": token.ID,
}, },
bson.M{ bson.M{
"$setOnInsert": bson.M{ "$setOnInsert": bson.M{