Add token ID to request log data
This commit is contained in:
16
src/mongo.go
16
src/mongo.go
@@ -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 {
|
||||
|
||||
@@ -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{
|
||||
|
||||
Reference in New Issue
Block a user