Skip to content

Commit

Permalink
Update user's last login when authenticating a peer
Browse files Browse the repository at this point in the history
Prior to this update the user's last login only updated on dashboard authentication
  • Loading branch information
mlsmaycon committed Jan 5, 2024
1 parent fd8bba6 commit ce057e6
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion management/server/peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ import (
"strings"
"time"

"github.com/netbirdio/management-integrations/additions"
"github.com/rs/xid"

"github.com/netbirdio/management-integrations/additions"

"github.com/netbirdio/netbird/management/server/activity"
nbpeer "github.com/netbirdio/netbird/management/server/peer"
"github.com/netbirdio/netbird/management/server/status"
Expand Down Expand Up @@ -440,6 +441,11 @@ func (am *DefaultAccountManager) AddPeer(setupKey, userID string, peer *nbpeer.P
}
}

if addedByUser {
user := account.Users[userID]
user.LastLogin = newPeer.LastLogin
}

account.Peers[newPeer.ID] = newPeer
account.Network.IncSerial()
err = am.Store.SaveAccount(account)
Expand Down Expand Up @@ -550,6 +556,10 @@ func (am *DefaultAccountManager) LoginPeer(login PeerLogin) (*nbpeer.Peer, *Netw
updateRemotePeers = true
shouldStoreAccount = true

// sync user last login with peer last login
user := account.Users[login.UserID]
user.LastLogin = peer.LastLogin

am.StoreEvent(login.UserID, peer.ID, account.Id, activity.UserLoggedInPeer, peer.EventMeta(am.GetDNSDomain()))
}

Expand Down

0 comments on commit ce057e6

Please sign in to comment.