Cosmetic improvements

This commit is contained in:
Taras Kushnir
2026-01-08 20:31:08 +02:00
parent 7d1247848b
commit 19991f1fb7
3 changed files with 6 additions and 3 deletions

View File

@@ -2387,6 +2387,11 @@ func (impl *BusinessStoreImpl) TransferOrganization(ctx context.Context, user *d
return nil, ErrMaintenance
}
if org.UserID.Int32 != user.ID {
slog.WarnContext(ctx, "Organization is not owned by user", "orgID", org.ID, "userID", user.ID)
return nil, ErrInvalidInput
}
if org.UserID.Int32 == newOwner.ID {
slog.WarnContext(ctx, "Organization is already owned by this user", "orgID", org.ID, "userID", newOwner.ID)
return nil, ErrInvalidInput

View File

@@ -40,9 +40,9 @@ type orgSettingsRenderContext struct {
CsrfRenderContext
CurrentOrg *userOrg
NameError string
Members []*orgUser
CanEdit bool
CanTransfer bool
Members []*orgUser
}
type orgAuditLogsRenderContext struct {

View File

@@ -447,11 +447,9 @@ func (s *Server) transferOrg(w http.ResponseWriter, r *http.Request) {
newOwner := &members[idx].User
// Execute the transfer in a transaction
auditEvents, err := s.Store.WithTx(ctx, func(impl *db.BusinessStoreImpl) ([]*common.AuditLogEvent, error) {
return impl.TransferOrganization(ctx, user, org, newOwner)
})
if err != nil {
slog.ErrorContext(ctx, "Failed to transfer organization", common.ErrAttr(err))
s.RedirectError(http.StatusInternalServerError, w, r)