From d1f9f85a9e6f4259fe99727142afa40448be4f37 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 12 Jan 2025 16:32:13 +0545 Subject: [PATCH] Login-update --- AppShell.xaml | 8 ++- AppShell.xaml.cs | 31 +++++++++- Views/DashboardPage.xaml | 6 ++ Views/DashboardPage.xaml.cs | 15 +++-- Views/LoginPage.xaml | 19 +++++- Views/LoginPage.xaml.cs | 58 ++++++++---------- Views/ViewReportsPage.xaml | 5 +- Views/ViewReportsPage.xaml.cs | 10 ++- bin/Debug/net9.0-android/Justice.dll | Bin 471040 -> 476160 bytes bin/Debug/net9.0-android/Justice.pdb | Bin 54412 -> 55292 bytes .../com.companyname.justice-Signed.apk | Bin 13247700 -> 13247700 bytes .../com.companyname.justice-Signed.apk.idsig | Bin 112051 -> 112051 bytes .../com.companyname.justice.apk | Bin 13142606 -> 13142606 bytes .../net9.0-ios/iossimulator-x64/Justice.dll | Bin 470016 -> 475648 bytes .../net9.0-ios/iossimulator-x64/Justice.pdb | Bin 48160 -> 49036 bytes .../maccatalyst-x64/Justice.dll | Bin 470016 -> 475648 bytes .../maccatalyst-x64/Justice.pdb | Bin 48052 -> 48928 bytes .../win10-x64/Justice.dll | Bin 718848 -> 724480 bytes .../win10-x64/Justice.exe | Bin 266752 -> 266752 bytes .../win10-x64/Justice.pdb | Bin 75068 -> 75920 bytes 20 files changed, 106 insertions(+), 46 deletions(-) diff --git a/AppShell.xaml b/AppShell.xaml index b5ce1b2..2d127ce 100644 --- a/AppShell.xaml +++ b/AppShell.xaml @@ -7,7 +7,9 @@ Shell.FlyoutBehavior="Flyout" Title="Justice"> - - - + + + + + diff --git a/AppShell.xaml.cs b/AppShell.xaml.cs index d89c2e3..5d609f4 100644 --- a/AppShell.xaml.cs +++ b/AppShell.xaml.cs @@ -1,10 +1,39 @@ -namespace Justice +using Justice.Helpers; + +namespace Justice { public partial class AppShell : Shell { + public Command LogoutCommand { get; } public AppShell() { InitializeComponent(); + + Routing.RegisterRoute("LoginPage", typeof(Views.LoginPage)); + Routing.RegisterRoute("DashboardPage", typeof(Views.DashboardPage)); + Routing.RegisterRoute("ViewReportsPage", typeof(Views.ViewReportsPage)); + + LogoutCommand = new Command(async () => + { + AuthHelper.Logout(); + await Shell.Current.GoToAsync("//LoginPage"); + }); + + BindingContext = this; + + + } + + protected override async void OnNavigating(ShellNavigatingEventArgs args) + { + base.OnNavigating(args); + + // Check if user is authenticated + if (!AuthHelper.IsLoggedIn && args.Target.Location.OriginalString.Contains("ViewReportsPage") || !AuthHelper.IsLoggedIn && args.Target.Location.OriginalString.Contains("DashboardPage")) + { + args.Cancel(); // Prevent navigation + await Shell.Current.GoToAsync("//LoginPage"); + } } } } diff --git a/Views/DashboardPage.xaml b/Views/DashboardPage.xaml index 0a6e931..2b4d2c6 100644 --- a/Views/DashboardPage.xaml +++ b/Views/DashboardPage.xaml @@ -3,8 +3,14 @@ xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="Justice.Views.DashboardPage" Title="DashboardPage" BackgroundColor="WhiteSmoke"> + + +