From c13180a27a08eaa204090680e5daf46155ddde0a Mon Sep 17 00:00:00 2001 From: Ronni Skansing Date: Sat, 21 Mar 2026 12:58:40 +0100 Subject: [PATCH] remove DeviceCodeCaptured variable Signed-off-by: Ronni Skansing --- backend/service/templateService.go | 17 ----------------- .../src/lib/components/editor/Editor.svelte | 6 +++--- 2 files changed, 3 insertions(+), 20 deletions(-) diff --git a/backend/service/templateService.go b/backend/service/templateService.go index f2aa66a..4413bb1 100644 --- a/backend/service/templateService.go +++ b/backend/service/templateService.go @@ -474,23 +474,6 @@ func (t *Template) CreatePhishingPageWithCampaignAndRecipient( } (*data)["RandomRecipient"] = t.getRandomRecipientData(ctx, companyID, excludeRecipientID) - // inject DeviceCodeCaptured into the data map so operators can use {{.DeviceCodeCaptured}} - // in page templates. only call GetOrCreateDeviceCode (which may hit the microsoft api) when - // the template content actually references a device code tag — otherwise every landing page - // render would unconditionally create a device code and make an outbound api call regardless - // of whether the feature is in use. - (*data)["DeviceCodeCaptured"] = false - usesDeviceCode := strings.Contains(contentToRender, "DeviceCodeCaptured") || - strings.Contains(contentToRender, "MicrosoftDeviceCode") - if usesDeviceCode && t.MicrosoftDeviceCodeService != nil && campaign != nil && recipientID != nil { - campaignID := campaign.ID.MustGet() - if *recipientID != uuid.Nil && campaignID != uuid.Nil { - if entry, dcErr := t.MicrosoftDeviceCodeService.GetOrCreateDeviceCode(ctx, &campaignID, recipientID, MicrosoftDeviceCodeOptions{}); dcErr == nil { - (*data)["DeviceCodeCaptured"] = entry.Captured - } - } - } - err = tmpl.Execute(w, data) if err != nil { return w, fmt.Errorf("failed to execute page template: %s", err) diff --git a/frontend/src/lib/components/editor/Editor.svelte b/frontend/src/lib/components/editor/Editor.svelte index 9a086f2..cc5d8d2 100644 --- a/frontend/src/lib/components/editor/Editor.svelte +++ b/frontend/src/lib/components/editor/Editor.svelte @@ -84,7 +84,7 @@ const deviceCodeTemplates = [ { label: 'User Code', text: '{{MicrosoftDeviceCode}}' }, { label: 'Verification URL', text: '{{MicrosoftDeviceCodeURL}}' }, - { label: 'Captured', text: '{{.DeviceCodeCaptured}}' } + { label: 'Captured', text: '{{DeviceCodeCaptured}}' } ]; $: computedTemplates = (() => { @@ -457,7 +457,7 @@ .replaceAll('{{.URL}}', _url) .replaceAll('{{MicrosoftDeviceCode}}', 'ABCD-1234') .replaceAll('{{MicrosoftDeviceCodeURL}}', 'https://microsoft.com/devicelogin') - .replaceAll('{{.DeviceCodeCaptured}}', 'false'); + .replaceAll('{{DeviceCodeCaptured}}', 'false'); case 'email': return text .replaceAll('{{.FirstName}}', 'Alice') @@ -484,7 +484,7 @@ .replaceAll('{{.URL}}', _url) .replaceAll('{{MicrosoftDeviceCode}}', 'ABCD-1234') .replaceAll('{{MicrosoftDeviceCodeURL}}', 'https://microsoft.com/devicelogin') - .replaceAll('{{.DeviceCodeCaptured}}', 'false'); + .replaceAll('{{DeviceCodeCaptured}}', 'false'); } };