SMTP-Credentials und E_Mail-Adressen verschlüsselt abgelegt

This commit is contained in:
concierge committed 2026-11-16 15:43:51 +01:00
1 parent 781aa20253
commit 66659d9a23
32 files changed
+3276 -132

No files matched your search

+17 -2
View File
@@ -123,8 +123,13 @@ func (s *Store) UpdateTenant(ctx context.Context, tenant *Tenant) error {
// DeleteTenant removes a tenant and, through cascades, its planning data.
func (s *Store) DeleteTenant(ctx context.Context, id string) error {
_, err := s.db.ExecContext(ctx, "DELETE FROM tenants WHERE id=?", id)
return err
return s.transaction(ctx, func(tx *sql.Tx) error {
if _, err := tx.ExecContext(ctx, "DELETE FROM key_wrappers WHERE tenant_id=?", id); err != nil {
return err
}
_, err := tx.ExecContext(ctx, "DELETE FROM tenants WHERE id=?", id)
return err
})
}
func slugify(value string) string {
@@ -236,6 +241,16 @@ func (s *Store) CanAccessTenant(ctx context.Context, user *User, tenantID string
return count > 0
}
// CanManageSecrets reports whether the user may manage encrypted contacts and
// SMTP credentials. Administrators are deliberately excluded: only editors
// hold the keys for these scopes.
func (s *Store) CanManageSecrets(ctx context.Context, user *User, tenantID string) bool {
if user == nil || !user.Active || user.Role != RoleEditor {
return false
}
return s.CanAccessTenant(ctx, user, tenantID)
}
// CanEditTenant reports whether the user may change planning data.
func (s *Store) CanEditTenant(ctx context.Context, user *User, tenantID string) bool {
if user == nil || !user.Active {