This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<PackageReference Include="CommunityToolkit.Maui" Version="8.0.0" /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dotnet new maui -n NfcMauiApp | |
cd NfcMauiApp |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// In your LoginViewModel | |
private async Task OnLoginClicked() | |
{ | |
// ... auth logic | |
await _navigationService.NavigateToAsync("//Dashboard"); | |
} | |
// A simple navigation service in Core/Infrastructure/ | |
public class NavigationService : INavigationService | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
builder.Services.AddTransient<LoginPage>(); // Register the page | |
builder.Services.AddTransient<LoginViewModel>(); // Register the ViewModel | |
// Register the concrete service that implements the feature's interface | |
builder.Services.AddSingleton<IAuthService, AuthService>(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Features/Authentication/LoginViewModel.cs | |
public partial class LoginViewModel : ObservableObject | |
{ | |
private readonly IAuthService _authService; | |
private readonly INavigationService _navigationService; | |
[ObservableProperty] | |
private string _userName; | |
[ObservableProperty] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Features/Authentication/IAuthService.cs | |
public interface IAuthService | |
{ | |
Task<bool> LoginAsync(string username, string password); | |
Task<bool> LogoutAsync(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MyMauiApp/ | |
├── Features/ | |
│ ├── Authentication/ | |
│ │ ├── LoginPage.xaml | |
│ │ ├── LoginPage.xaml.cs | |
│ │ ├── LoginViewModel.cs | |
│ │ ├── LoginCommand.cs | |
│ │ └── IAuthService.cs // Feature-specific interface | |
│ ├── Dashboard/ | |
│ │ ├── DashboardPage.xaml |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MyMauiApp/ | |
├── Views/ | |
├── ViewModels/ | |
├── Models/ | |
├── Services/ | |
└── Repositories/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var isAuthenticated = await BiometricAuthenticationService.AuthenticateAsync(); | |
if (isAuthenticated) | |
{ | |
// Proceed to load the private key and sign | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[HttpPost("verifyLogin")] | |
public async Task<IActionResult> VerifyLogin([FromBody] LoginVerificationRequest request) | |
{ | |
// 1. Find the user and their stored public key | |
var user = await _context.Users.FirstOrDefaultAsync(u => u.Username == request.Username); | |
if (user == null) return Unauthorized(); | |
// 2. Recreate the original challenge that was sent to this user | |
// (You would need to store this challenge temporarily with an expiry) | |
byte[] challengeBytes = GetStoredChallengeForUser(user.Username); |