Skip to content

Conversation

AaronSadlerUK
Copy link
Contributor

Updated members two factor example code for Umbraco v16

📋 Description

Updated the example code in the documentation to work with Umbraco v16

📎 Related Issues (if applicable)

Solves:
umbraco/Umbraco-CMS#18880

Updated members two factor example code for Umbraco v16
@eshanrnh
Copy link
Contributor

eshanrnh commented Oct 8, 2025

Thanks for the PR, @AaronSadlerUK 🙌 We will review it asap.

Copy link
Contributor

@eshanrnh eshanrnh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AaronSadlerUK Thanks again for updating the code snippet. However, I had to make a few small adjustments to get the code working, which I have added as suggestions. Without these changes, the proposed snippet was throwing compilation errors.

Could you take a look and let me know if anything doesn’t make sense?

{% code title="ExampleMemberPage.cshtml" lineNumbers="true" %}

```csharp
@using Umbraco.Cms.Core.Services;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@using Umbraco.Cms.Core.Services;
@using Umbraco.Cms.Core.Models;

{
var setupData = await twoFactorLoginService.GetSetupInfoAsync(profileModel.Key, providerName);
foreach (var provider in providerNameList)
{0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{0
{

<button type="submit">Disable @providerName</button>
@using (Html.BeginUmbracoForm<UmbTwoFactorLoginController>(nameof(UmbTwoFactorLoginController.ValidateAndSaveSetup)))
{
<h3>Setup @providerName</h3>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<h3>Setup @providerName</h3>
<h3>Setup @provider.ProviderName</h3>

<h3>Setup @providerName</h3>
<img src="@qrCodeSetupData.SetupCode.QrCodeSetupImageUrl"/>
<p>Scan the code above with your authenticator app <br /> and enter the resulting code here to validate:</p>
<input type="hidden" name="providerName" value="@providerName" />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<input type="hidden" name="providerName" value="@providerName" />
<input type="hidden" name="providerName" value="@provider.ProviderName" />

Comment on lines +228 to +229
<input type="hidden" name="providerName" value="@providerName"/>
<button type="submit">Disable @providerName</button>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<input type="hidden" name="providerName" value="@providerName"/>
<button type="submit">Disable @providerName</button>
<input type="hidden" name="providerName" value="@provider.ProviderName" />
<button type="submit">Disable @provider.ProviderName</button>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants