aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2018-11-26 13:37:11 +0200
committerRoy Ben-Shabat <Roy@Twine-s.com>2018-11-26 13:37:11 +0200
commit10a9435c7fece43c588addb744952d92596a8f5b (patch)
treef3a05a18a437b64f8876cf193497eaa054d7dc57 /Software/Visual_Studio
parent0821e00982f13f234c4e83def85b2d49a5fed9b8 (diff)
downloadTango-10a9435c7fece43c588addb744952d92596a8f5b.tar.gz
Tango-10a9435c7fece43c588addb744952d92596a8f5b.zip
Implemented single user mode on PPC.
Diffstat (limited to 'Software/Visual_Studio')
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.Common/Authentication/IAuthenticationProvider.cs3
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/Authentication/DefaultAuthenticationProvider.cs7
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoadingViewVM.cs22
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LoadingView.xaml8
4 files changed, 30 insertions, 10 deletions
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Authentication/IAuthenticationProvider.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Authentication/IAuthenticationProvider.cs
index dd7faae36..33761c8d6 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Authentication/IAuthenticationProvider.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Authentication/IAuthenticationProvider.cs
@@ -27,8 +27,9 @@ namespace Tango.PPC.Common.Authentication
/// </summary>
/// <param name="email">The email.</param>
/// <param name="password">The password.</param>
+ /// <param name="encrypt">Determines whether to encrypt the provided password before attempting to login</param>
/// <returns></returns>
- Task<User> Login(String email, String password);
+ Task<User> Login(String email, String password, bool encrypt = true);
/// <summary>
/// Logs-out the current logged-in user.
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Authentication/DefaultAuthenticationProvider.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Authentication/DefaultAuthenticationProvider.cs
index 23761eb9b..04e968da2 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Authentication/DefaultAuthenticationProvider.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Authentication/DefaultAuthenticationProvider.cs
@@ -50,12 +50,13 @@ namespace Tango.PPC.UI.Authentication
/// </summary>
/// <param name="email">The email.</param>
/// <param name="password">The password.</param>
+ /// <param name="encrypt">Determines whether to encrypt the provided password before attempting to login</param>
/// <returns></returns>
- public Task<User> Login(string email, string password)
+ public Task<User> Login(string email, string password, bool encrypt = true)
{
- return Task.Factory.StartNew<User>(() =>
+ return Task.Factory.StartNew<User>(() =>
{
- String hash = User.GetPasswordHash(password);
+ String hash = encrypt ? User.GetPasswordHash(password) : password;
LogManager.Log($"Logging in user {email}...");
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 852997f87..486829103 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoadingViewVM.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoadingViewVM.cs
@@ -19,6 +19,7 @@ using Tango.PPC.Common.Notifications;
using Tango.PPC.Common.Notifications.NotificationItems;
using Tango.PPC.Jobs;
using Tango.SharedUI;
+using System.Data.Entity;
namespace Tango.PPC.UI.ViewModels
{
@@ -58,11 +59,24 @@ namespace Tango.PPC.UI.ViewModels
/// <summary>
/// Called when the application has been started.
/// </summary>
- public override void OnApplicationStarted()
+ public async override void OnApplicationStarted()
{
- IsLoading = false;
- LogManager.Log("Application started. Navigating to LoginView...");
- NavigationManager.NavigateTo(NavigationView.LoginView);
+ using (ObservablesContext db = ObservablesContext.CreateDefault())
+ {
+ if (db.Users.Count() == 1)
+ {
+ var user = await db.Users.FirstAsync();
+ LogManager.Log($"Application started. Single user detected ({user.Email}). Skipping LoginView...");
+ await AuthenticationProvider.Login(user.Email, user.Password, false);
+ IsLoading = false;
+ }
+ else
+ {
+ LogManager.Log("Application started. Navigating to LoginView...");
+ await NavigationManager.NavigateTo(NavigationView.LoginView);
+ IsLoading = false;
+ }
+ }
}
}
}
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LoadingView.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LoadingView.xaml
index 36baf413d..895619807 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LoadingView.xaml
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LoadingView.xaml
@@ -13,7 +13,7 @@
d:DesignHeight="1280" d:DesignWidth="800" d:DataContext="{d:DesignInstance Type=vm:LoadingViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.LoadingView}">
<Grid>
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
- <Image gif:ImageBehavior.EnableAnimation="{Binding IsLoading}" gif:ImageBehavior.AnimatedSource="/Images/Twine_Loading_GIF.gif" Margin="100" RenderTransformOrigin="0.5,0.5" RenderOptions.BitmapScalingMode="Fant">
+ <Image gif:ImageBehavior.EnableAnimation="{Binding IsLoading}" gif:ImageBehavior.AnimatedSource="/Images/Twine_Loading_GIF.gif" Margin="100 100 100 0" RenderTransformOrigin="0.5,0.5" RenderOptions.BitmapScalingMode="Fant" Height="382">
<Image.Style>
<Style TargetType="Image">
<Setter Property="RenderTransform">
@@ -46,7 +46,11 @@
</Style>
</Image.Style>
</Image>
- <TextBlock FontSize="{StaticResource TangoHeaderFontSize}" Margin="20" HorizontalAlignment="Center" Width="150">
+
+ <TextBlock Margin="0 40 0 0" HorizontalAlignment="Center" FontSize="{StaticResource TangoTitleFontSize}" Foreground="{StaticResource TangoGrayTextBrush}">
+ <Run>v</Run><Run Text="{Binding ApplicationManager.Version,Mode=OneWay}"></Run>
+ </TextBlock>
+ <TextBlock FontSize="{StaticResource TangoHeaderFontSize}" Margin="0 100 0 0" HorizontalAlignment="Center" Width="150">
<TextBlock.Style>
<Style TargetType="TextBlock">
<Setter Property="Text" Value="Loading"></Setter>