chore: omit associations by default

This commit is contained in:
Johan Siebens
2024-02-10 13:35:43 +01:00
parent b098562988
commit cf8b2be0e8
3 changed files with 10 additions and 5 deletions
+2 -1
View File
@@ -5,6 +5,7 @@ import (
"encoding/json"
"github.com/jsiebens/ionscale/internal/util"
"gorm.io/gorm"
"gorm.io/gorm/clause"
"net/http"
"sync"
"tailscale.com/tailcfg"
@@ -98,7 +99,7 @@ type repository struct {
}
func (r *repository) withContext(ctx context.Context) *gorm.DB {
return r.db.WithContext(ctx)
return r.db.WithContext(ctx).Omit(clause.Associations)
}
func (r *repository) Transaction(action func(Repository) error) error {
+2
View File
@@ -480,7 +480,9 @@ func (h *AuthenticationHandlers) endMachineRegistrationFlow(c echo.Context, form
Authorized: !tailnet.MachineAuthorizationEnabled || authorized,
User: *user,
UserID: user.ID,
Tailnet: *tailnet,
TailnetID: tailnet.ID,
}
ipv4, ipv6, err := addr.SelectIP(checkIP(ctx, h.repository.CountMachinesWithIPv4))
+2
View File
@@ -203,7 +203,9 @@ func (h *RegistrationHandlers) authenticateMachineWithAuthKey(c echo.Context, ma
Authorized: !tailnet.MachineAuthorizationEnabled || authKey.PreAuthorized,
User: user,
UserID: user.ID,
Tailnet: tailnet,
TailnetID: tailnet.ID,
}
if !req.Expiry.IsZero() {