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,18 +31,18 @@ type Application struct {
ShortDescription string `bson:"shortDescription" json:"shortDescription"`
User string `bson:"user" json:"user"`
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"`
}
type Token struct {
ID string `bson:"_id" json:"id"`
Name string `bson:"name" json:"name"`
Token string `bson:"token" json:"token"`
TotalRequests uint64 `bson:"totalRequests" json:"totalRequests"`
Application string `bson:"application" json:"application"`
CreatedAt time.Time `bson:"createdAt" json:"createdAt"`
LastUsedAt time.Time `bson:"lastUsedAt" json:"lastUsedAt"`
ID string `bson:"_id" json:"id"`
Name string `bson:"name" json:"name"`
Token string `bson:"token" json:"token"`
RequestCount uint64 `bson:"requestCount" json:"requestCount"`
Application string `bson:"application" json:"application"`
CreatedAt time.Time `bson:"createdAt" json:"createdAt"`
LastUsedAt time.Time `bson:"lastUsedAt" json:"lastUsedAt"`
}
func (c *MongoDB) Connect() error {

View File

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