Skip to content

Commit 343900a

Browse files
committed
Update NuGet packages and refactor QR code generation
Updated NuGet packages in `TwoFactorAuthenticationSample.DataAccessLayer.csproj` and `TwoFactorAuthenticationSample.csproj` to newer versions, including `Microsoft.AspNetCore.DataProtection.EntityFrameworkCore`, `Microsoft.AspNetCore.Identity.EntityFrameworkCore`, `Microsoft.EntityFrameworkCore.SqlServer`, `Microsoft.AspNetCore.OpenApi`, `Microsoft.EntityFrameworkCore.Tools`, `QRCoder`, `SimpleAuthenticationTools`, `SimpleAuthenticationTools.Swashbuckle`, `TinyHelpers.AspNetCore`, and `TinyHelpers.AspNetCore.Swashbuckle`. Refactored QR code generation in `Program.cs` to use `PayloadGenerator.OneTimePassword` for encapsulating data, improving code clarity and maintainability.
1 parent 153cb11 commit 343900a

3 files changed

Lines changed: 17 additions & 12 deletions

File tree

TwoFactorAuthenticationSample.DataAccessLayer/TwoFactorAuthenticationSample.DataAccessLayer.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="Microsoft.AspNetCore.DataProtection.EntityFrameworkCore" Version="9.0.9" />
11-
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="9.0.9" />
12-
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="9.0.9" />
10+
<PackageReference Include="Microsoft.AspNetCore.DataProtection.EntityFrameworkCore" Version="9.0.10" />
11+
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="9.0.10" />
12+
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="9.0.10" />
1313
</ItemGroup>
1414

1515
</Project>

TwoFactorAuthenticationSample/Program.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,15 @@
130130
await userManager.ResetAuthenticatorKeyAsync(user);
131131
var secret = await userManager.GetAuthenticatorKeyAsync(user);
132132

133-
var qrCodeUri = $"otpauth://totp/{Uri.EscapeDataString(environment.ApplicationName)}:{user.Email}?secret={secret}&issuer={Uri.EscapeDataString(environment.ApplicationName)}";
133+
var payload = new PayloadGenerator.OneTimePassword
134+
{
135+
Issuer = environment.ApplicationName,
136+
Secret = secret!,
137+
Label = user.Email
138+
};
134139

135140
using var qrCodeGenerator = new QRCodeGenerator();
136-
using var qrCodeData = qrCodeGenerator.CreateQrCode(qrCodeUri, QRCodeGenerator.ECCLevel.Q);
141+
using var qrCodeData = qrCodeGenerator.CreateQrCode(payload, QRCodeGenerator.ECCLevel.Q);
137142
using var qrCode = new PngByteQRCode(qrCodeData);
138143

139144
var qrCodeBytes = qrCode.GetGraphic(3);

TwoFactorAuthenticationSample/TwoFactorAuthenticationSample.csproj

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,18 @@
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="9.0.9" />
11-
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="9.0.9">
10+
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="9.0.10" />
11+
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="9.0.10">
1212
<PrivateAssets>all</PrivateAssets>
1313
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1414
</PackageReference>
1515
<PackageReference Include="Otp.NET" Version="1.4.0" />
16-
<PackageReference Include="QRCoder" Version="1.6.0" />
17-
<PackageReference Include="SimpleAuthenticationTools" Version="3.0.15" />
18-
<PackageReference Include="SimpleAuthenticationTools.Swashbuckle" Version="3.0.23" />
16+
<PackageReference Include="QRCoder" Version="1.7.0" />
17+
<PackageReference Include="SimpleAuthenticationTools" Version="3.1.6" />
18+
<PackageReference Include="SimpleAuthenticationTools.Swashbuckle" Version="3.1.6" />
1919
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="9.0.6" />
20-
<PackageReference Include="TinyHelpers.AspNetCore" Version="4.1.6" />
21-
<PackageReference Include="TinyHelpers.AspNetCore.Swashbuckle" Version="4.0.26" />
20+
<PackageReference Include="TinyHelpers.AspNetCore" Version="4.1.8" />
21+
<PackageReference Include="TinyHelpers.AspNetCore.Swashbuckle" Version="4.0.30" />
2222
</ItemGroup>
2323

2424
<ItemGroup>

0 commit comments

Comments
 (0)