diff --git a/App.xaml.cs b/App.xaml.cs index 5e4165e..c5091e3 100644 --- a/App.xaml.cs +++ b/App.xaml.cs @@ -19,7 +19,11 @@ namespace Justice var dbHelper = new DatabaseHelper(); await dbHelper.InitializeAsync(); await dbHelper.InitializeAsync(); - await dbHelper.InitializeAsync();// Asynchronously create the EmergencyContact table + await dbHelper.InitializeAsync(); + Task.Run(async () => + { + await dbHelper.InitializeAsync(); // Initialize the User table + }).Wait();// Asynchronously create the EmergencyContact table } catch (Exception ex) { diff --git a/AppShell.xaml b/AppShell.xaml index 2d127ce..4f87549 100644 --- a/AppShell.xaml +++ b/AppShell.xaml @@ -10,6 +10,7 @@ + diff --git a/Helpers/AuthHelper.cs b/Helpers/AuthHelper.cs new file mode 100644 index 0000000..04a3456 --- /dev/null +++ b/Helpers/AuthHelper.cs @@ -0,0 +1,27 @@ +using Microsoft.Maui.Storage; + +namespace Justice.Helpers +{ + public static class AuthHelper + { + private const string IsLoggedInKey = "IsLoggedIn"; + private const string UserRoleKey = "UserRole"; + + public static bool IsLoggedIn => Preferences.Get(IsLoggedInKey, false); + + public static string UserRole => Preferences.Get(UserRoleKey, string.Empty); + + public static void Login(string role) + { + Preferences.Set(IsLoggedInKey, true); + Preferences.Set(UserRoleKey, role); + } + + public static void Logout() + { + Preferences.Remove(IsLoggedInKey); + Preferences.Remove(UserRoleKey); + + } + } +} diff --git a/Models/User.cs b/Models/User.cs index 15dd6d5..49c2924 100644 --- a/Models/User.cs +++ b/Models/User.cs @@ -13,6 +13,7 @@ namespace Justice.Models public string Password { get; set; } public string Role { get; set; } public string AuthorityType { get; set; } + public string IdentityFilePath { get; set; } } public class AuthorityUser : User { diff --git a/Views/DashboardPage.xaml b/Views/DashboardPage.xaml index 2b4d2c6..177a4f6 100644 --- a/Views/DashboardPage.xaml +++ b/Views/DashboardPage.xaml @@ -3,19 +3,21 @@ xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="Justice.Views.DashboardPage" Title="DashboardPage" BackgroundColor="WhiteSmoke"> - + - -