diff options
| author | Shlomo Hecht <shlomo@twine-s.com> | 2018-12-17 09:41:41 +0200 |
|---|---|---|
| committer | Shlomo Hecht <shlomo@twine-s.com> | 2018-12-17 09:41:41 +0200 |
| commit | 9562ca15079cdbf2bcfd11c8c8def4a8e4573a78 (patch) | |
| tree | 480bb5f4a49a398d789197006e66ca76d78ff007 /Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels | |
| parent | fc23da7f3510cce58308841eefb96d59868317ff (diff) | |
| parent | d8d1128887089087578286f37561dc8942726ba4 (diff) | |
| download | Tango-9562ca15079cdbf2bcfd11c8c8def4a8e4573a78.tar.gz Tango-9562ca15079cdbf2bcfd11c8c8def4a8e4573a78.zip | |
Merge branch 'master' of https://twinetfs.visualstudio.com/Tango/_git/Tango
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels')
3 files changed, 47 insertions, 3 deletions
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoadingViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoadingViewVM.cs index 281e54958..516349a18 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoadingViewVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoadingViewVM.cs @@ -20,6 +20,7 @@ using Tango.PPC.Common.Notifications.NotificationItems; using Tango.PPC.Jobs; using Tango.SharedUI; using System.Data.Entity; +using Tango.BL.Enumerations; namespace Tango.PPC.UI.ViewModels { @@ -79,6 +80,7 @@ namespace Tango.PPC.UI.ViewModels if (db.Users.Count() == 1 || machine.AutoLogin) { var user = await db.Users.FirstAsync(); + LogManager.Log($"Application started. Single user/Auto login detected ({user.Email}). Skipping LoginView..."); await AuthenticationProvider.Login(user.Email, user.Password, false); IsLoading = false; diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoginViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoginViewVM.cs index 9d17a4a76..aa9689ef3 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoginViewVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoginViewVM.cs @@ -11,6 +11,8 @@ using System.ComponentModel.DataAnnotations; using Tango.SharedUI.Helpers; using Tango.PPC.Common.Authentication; using Tango.BL.Entities; +using Tango.BL.Enumerations; +using Tango.Logging; namespace Tango.PPC.UI.ViewModels { @@ -89,9 +91,19 @@ namespace Tango.PPC.UI.ViewModels base.OnApplicationReady(); await Task.Delay(500); - LogManager.Log("Application is ready! Navigating to home module..."); - await NavigationManager.NavigateTo(NavigationView.HomeModule); - IsLoading = false; + + if (AuthenticationProvider.CurrentUser != null && AuthenticationProvider.CurrentUser.HasPermission(Permissions.RunPPC)) + { + LogManager.Log("Application is ready! Navigating to home module..."); + await NavigationManager.NavigateTo(NavigationView.HomeModule); + IsLoading = false; + } + else + { + LogManager.Log("Application is ready! The logged in user does not have permission to run the application!", LogCategory.Warning); + await NavigationManager.NavigateTo(NavigationView.NoPermissionsView); + IsLoading = false; + } } #endregion diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/NoPermissionsViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/NoPermissionsViewVM.cs new file mode 100644 index 000000000..cea8a7d63 --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/NoPermissionsViewVM.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Core.Commands; +using Tango.PPC.Common; + +namespace Tango.PPC.UI.ViewModels +{ + public class NoPermissionsViewVM : PPCViewModel + { + public RelayCommand RestartCommand { get; set; } + + public NoPermissionsViewVM() + { + RestartCommand = new RelayCommand(Restart); + } + + private void Restart() + { + ApplicationManager.Restart(); + } + + public override void OnApplicationStarted() + { + + } + } +} |
