Skip to content

Commit

Permalink
Cleanup and standardize user id for logs
Browse files Browse the repository at this point in the history
  • Loading branch information
antoniomika committed Nov 17, 2024
1 parent 7225c57 commit 7e4ad3e
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion db/postgres/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ func (me *PsqlDB) FindUserForKey(username string, key string) (*db.User, error)
me.Logger.Info("attempting to find user with only public key", "key", key)
pk, err := me.FindPublicKeyForKey(key)
if err == nil {
me.Logger.Info("found pubkey, looking for user", "key", key, "userID", pk.UserID)
me.Logger.Info("found pubkey, looking for user", "key", key, "userId", pk.UserID)
user, err := me.FindUser(pk.UserID)
if err != nil {
return nil, err
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ require (
github.com/picosh/pubsub v0.0.0-20241114191831-ec8f16c0eb88
github.com/picosh/send v0.0.0-20241107150437-0febb0049b4f
github.com/picosh/tunkit v0.0.0-20240905223921-532404cef9d9
github.com/picosh/utils v0.0.0-20241117214552-6372620615c4
github.com/picosh/utils v0.0.0-20241117232851-a32d4675d449
github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06
github.com/sendgrid/sendgrid-go v3.16.0+incompatible
github.com/simplesurance/go-ip-anonymizer v0.0.0-20200429124537-35a880f8e87d
Expand Down
6 changes: 2 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -277,10 +277,8 @@ github.com/picosh/senpai v0.0.0-20240503200611-af89e73973b0 h1:pBRIbiCj7K6rGELij
github.com/picosh/senpai v0.0.0-20240503200611-af89e73973b0/go.mod h1:QaBDtybFC5gz7EG/9c3bgzuyW7W5W2rYLFZxWNuWk3Q=
github.com/picosh/tunkit v0.0.0-20240905223921-532404cef9d9 h1:g5oZmnDFr11HarA8IAXcc4o9PBlolSM59QIATCSoato=
github.com/picosh/tunkit v0.0.0-20240905223921-532404cef9d9/go.mod h1:UrDH/VCIc1wg/L6iY2zSYt4TiGw+25GsKSnkVkU40Dw=
github.com/picosh/utils v0.0.0-20241117203114-3decbe6f0cec h1:syh21+XscCDAWFimYTyeJL+LQXTsKz+/mv5cHw6l2Cc=
github.com/picosh/utils v0.0.0-20241117203114-3decbe6f0cec/go.mod h1:HogYEyJ43IGXrOa3D/kjM1pkzNAyh+pejRyv8Eo//pk=
github.com/picosh/utils v0.0.0-20241117214552-6372620615c4 h1:p+ZsJGcQWUnMY2O6621/vdXl0GLagli6VvMgFs0AAYI=
github.com/picosh/utils v0.0.0-20241117214552-6372620615c4/go.mod h1:HogYEyJ43IGXrOa3D/kjM1pkzNAyh+pejRyv8Eo//pk=
github.com/picosh/utils v0.0.0-20241117232851-a32d4675d449 h1:hXJPjYl0y9YD0EqqST3j4oqCEKQJzZwNTg/iHgD40wo=
github.com/picosh/utils v0.0.0-20241117232851-a32d4675d449/go.mod h1:HogYEyJ43IGXrOa3D/kjM1pkzNAyh+pejRyv8Eo//pk=
github.com/pkg/sftp v1.13.7 h1:uv+I3nNJvlKZIQGSr8JVQLNHFU9YhhNpvC14Y6KgmSM=
github.com/pkg/sftp v1.13.7/go.mod h1:KMKI0t3T6hfA+lTR/ssZdunHo+uwq7ghoN09/FSu3DY=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
Expand Down
3 changes: 2 additions & 1 deletion pico/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ func (c *Cmd) logs(ctx context.Context) error {
}

user := utils.AnyToStr(parsedData, "user")
if user == c.User.Name {
userId := utils.AnyToStr(parsedData, "userId")
if user == c.User.Name || userId == c.User.ID {
wish.Println(c.SshSession, line)
}
}
Expand Down
3 changes: 2 additions & 1 deletion tui/logs/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,8 @@ func (m Model) connectLogs(sub chan map[string]any) tea.Cmd {
}

user := utils.AnyToStr(parsedData, "user")
if user == m.shared.User.Name {
userId := utils.AnyToStr(parsedData, "userId")
if user == m.shared.User.Name || userId == m.shared.User.ID {
sub <- parsedData
}
}
Expand Down

0 comments on commit 7e4ad3e

Please sign in to comment.