NFC azonosítás is beállítva
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using CommunityToolkit.Maui.Alerts;
|
||||
using CommunityToolkit.Maui.Core;
|
||||
using System.Drawing;
|
||||
using WorkFlowCheck.MAUI.Pages.NFC;
|
||||
using WorkFlowCheck.MAUI.Services.Interfaces;
|
||||
|
||||
namespace WorkFlowCheck.MAUI.Pages.Security;
|
||||
@@ -29,7 +30,7 @@ public partial class LoginPage : ContentPage
|
||||
if (response != null && response.IsSuccess)
|
||||
{
|
||||
_userService.SetCurrentUser(response.Data);
|
||||
|
||||
|
||||
//await _syncService.SyncDatas();
|
||||
|
||||
var wFCUser = Newtonsoft.Json.JsonConvert.SerializeObject(response.Data);
|
||||
@@ -40,14 +41,14 @@ public partial class LoginPage : ContentPage
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
|
||||
var visualOptions = new SnackbarOptions
|
||||
{
|
||||
ActionButtonTextColor = Colors.Yellow,
|
||||
CornerRadius = new CornerRadius(10),
|
||||
Font = Microsoft.Maui.Font.SystemFontOfSize(16),
|
||||
BackgroundColor = Microsoft.Maui.Graphics.Color.Parse("Red"),
|
||||
TextColor=Colors.Yellow
|
||||
TextColor = Colors.Yellow
|
||||
|
||||
};
|
||||
var snackbar = Snackbar.Make(
|
||||
@@ -77,4 +78,71 @@ public partial class LoginPage : ContentPage
|
||||
}
|
||||
|
||||
}
|
||||
private async void OnLoginNFCClicked(object sender, EventArgs e)
|
||||
{
|
||||
LoadingIndicator.IsRunning = true;
|
||||
LoadingIndicator.IsVisible = true;
|
||||
LoginBtn.IsEnabled = false;
|
||||
LoginNFCBtn.IsEnabled = false;
|
||||
UsernameEntry.IsEnabled = false;
|
||||
PasswordEntry.IsEnabled = false;
|
||||
try
|
||||
{
|
||||
var nFCCode = await NFCWaiter.ShowModalAsync();
|
||||
if (!string.IsNullOrEmpty(nFCCode))
|
||||
{
|
||||
var response = await _userService.AuthenticateNFC(nFCCode);
|
||||
|
||||
if (response != null && response.IsSuccess)
|
||||
{
|
||||
_userService.SetCurrentUser(response.Data);
|
||||
|
||||
//await _syncService.SyncDatas();
|
||||
|
||||
var wFCUser = Newtonsoft.Json.JsonConvert.SerializeObject(response.Data);
|
||||
await SecureStorage.Default.SetAsync("WFCUser", "wFCUser");
|
||||
await SecureStorage.Default.SetAsync("AuthToken", response.Data.JwtToken);
|
||||
|
||||
await Shell.Current.GoToAsync("//SyncPage");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
var visualOptions = new SnackbarOptions
|
||||
{
|
||||
ActionButtonTextColor = Colors.Yellow,
|
||||
CornerRadius = new CornerRadius(10),
|
||||
Font = Microsoft.Maui.Font.SystemFontOfSize(16),
|
||||
BackgroundColor = Microsoft.Maui.Graphics.Color.Parse("Red"),
|
||||
TextColor = Colors.Yellow
|
||||
|
||||
};
|
||||
var snackbar = Snackbar.Make(
|
||||
"Invalid login credentials.",
|
||||
duration: TimeSpan.FromSeconds(10),
|
||||
action: () => Console.WriteLine("Snackbar dismissed"),
|
||||
actionButtonText: "OK",
|
||||
visualOptions: visualOptions
|
||||
);
|
||||
|
||||
await snackbar.Show();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
throw;
|
||||
}
|
||||
finally
|
||||
{
|
||||
LoginBtn.IsEnabled = true;
|
||||
LoadingIndicator.IsRunning = false;
|
||||
LoadingIndicator.IsVisible = false;
|
||||
UsernameEntry.IsEnabled = true;
|
||||
PasswordEntry.IsEnabled = true;
|
||||
LoginNFCBtn.IsEnabled = true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user