remove DeviceCodeCaptured variable

Signed-off-by: Ronni Skansing <rskansing@gmail.com>
This commit is contained in:
Ronni Skansing
2026-03-21 12:58:40 +01:00
parent fc5e8e199b
commit c13180a27a
2 changed files with 3 additions and 20 deletions
-17
View File
@@ -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)
@@ -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');
}
};