[management] apply login filter only for setup key peers (#4943)

This commit is contained in:
Pascal Fischer
2025-12-30 10:46:00 +01:00
committed by GitHub
parent 4035f07248
commit 1d2c7776fd
7 changed files with 100 additions and 2 deletions

View File

@@ -4082,3 +4082,21 @@ func (s *SqlStore) GetPeersByGroupIDs(ctx context.Context, accountID string, gro
return peers, nil
}
func (s *SqlStore) GetUserIDByPeerKey(ctx context.Context, lockStrength LockingStrength, peerKey string) (string, error) {
tx := s.db
if lockStrength != LockingStrengthNone {
tx = tx.Clauses(clause.Locking{Strength: string(lockStrength)})
}
var userID string
result := tx.Model(&nbpeer.Peer{}).
Select("user_id").
Take(&userID, GetKeyQueryCondition(s), peerKey)
if result.Error != nil {
return "", status.Errorf(status.Internal, "failed to get user ID by peer key")
}
return userID, nil
}