diff --git a/Guard/App.xaml.cs b/Guard/App.xaml.cs
index 03fdf8f..46fa2f2 100644
--- a/Guard/App.xaml.cs
+++ b/Guard/App.xaml.cs
@@ -1,11 +1,12 @@
-using Guard.Core;
+using System.Diagnostics;
+using System.Runtime.InteropServices;
+using System.Windows;
+using Guard.Core;
using Guard.Core.Installation;
using Guard.Core.Security;
using Guard.Core.Storage;
using NSec.Cryptography;
-using System.Diagnostics;
-using System.Runtime.InteropServices;
-using System.Windows;
+using Serilog.Core;
using Windows.ApplicationModel.Activation;
namespace Guard
@@ -110,6 +111,40 @@ protected override async void OnStartup(StartupEventArgs e)
return;
}
+ Version currentVersion = InstallationInfo.GetVersion();
+ if (
+ SettingsManager.Settings.LastUsedAppVersion.Major == 0
+ && SettingsManager.Settings.LastUsedAppVersion.Minor == 0
+ )
+ {
+ SettingsManager.Settings.LastUsedAppVersion = currentVersion;
+ _ = SettingsManager.Save();
+ }
+ int versionCompare = SettingsManager.Settings.LastUsedAppVersion.CompareTo(
+ currentVersion
+ );
+ if (versionCompare < 0)
+ {
+ SettingsManager.Settings.LastUsedAppVersion = currentVersion;
+ _ = SettingsManager.Save();
+ }
+ else if (versionCompare > 0)
+ {
+ Log.Logger.Error(
+ "Preventing app start: Current version is older than last used version: {0} < {1}",
+ currentVersion,
+ SettingsManager.Settings.LastUsedAppVersion
+ );
+ var uiMessageBox = new Wpf.Ui.Controls.MessageBox
+ {
+ Title = I18n.GetString("i.unsupported.olderversion.title"),
+ Content = I18n.GetString("i.unsupported.olderversion.content"),
+ CloseButtonText = I18n.GetString("i.unsupported.exit"),
+ };
+ await uiMessageBox.ShowDialogAsync();
+ Shutdown();
+ }
+
if (!autostart)
{
autostart = e.Args != null && e.Args.Contains("--autostart");
@@ -137,6 +172,7 @@ protected override void OnActivated(EventArgs e)
InactivityDetector.OnFocusGained();
base.OnActivated(e);
}
+
protected override void OnDeactivated(EventArgs e)
{
InactivityDetector.OnFocusLost();
diff --git a/Guard/Core/Installation/InstallationInfo.cs b/Guard/Core/Installation/InstallationInfo.cs
index 2a60b24..df04e09 100644
--- a/Guard/Core/Installation/InstallationInfo.cs
+++ b/Guard/Core/Installation/InstallationInfo.cs
@@ -52,8 +52,13 @@ internal static string GetInstallationTypeString()
internal static string GetVersionString()
{
- return System.Reflection.Assembly.GetExecutingAssembly().GetName().Version?.ToString()
- ?? "????";
+ return GetVersion().ToString() ?? "????";
+ }
+
+ internal static Version GetVersion()
+ {
+ return System.Reflection.Assembly.GetExecutingAssembly().GetName().Version
+ ?? new Version(0, 0);
}
internal static string GetAppDataFolderPath()
diff --git a/Guard/Core/Models/AppSettings.cs b/Guard/Core/Models/AppSettings.cs
index 0b72f8a..06b933c 100644
--- a/Guard/Core/Models/AppSettings.cs
+++ b/Guard/Core/Models/AppSettings.cs
@@ -1,4 +1,6 @@
-namespace Guard.Core.Models
+using Guard.Core.Installation;
+
+namespace Guard.Core.Models
{
internal enum ThemeSetting
{
@@ -43,5 +45,6 @@ internal class AppSettings
public bool ShowTokenCardIntro { get; set; } = true;
public bool MinimizeToTray { get; set; } = false;
public LockTimeSetting LockTime { get; set; } = LockTimeSetting.TenMinutes;
+ public Version LastUsedAppVersion { get; set; } = new(0, 0);
}
}
diff --git a/Guard/Resources/Strings.de.xaml b/Guard/Resources/Strings.de.xaml
index fdb99bf..d94d5e6 100644
--- a/Guard/Resources/Strings.de.xaml
+++ b/Guard/Resources/Strings.de.xaml
@@ -272,4 +272,6 @@
Visual C++ Redistributable nicht installiert
Die Software Microsoft Visual C++ Redistributable 2015-2022 ist nicht installiert. Bitte installiere das Paket, um 2FAGuard verwenden zu können. Falls du den 2FAGuard Installer verwendet hast oder das Paket gerade installiert hast, musst du eventuell dein Gerät neu starten.
Herunterladen
+ Veraltete App-Version
+ Du verwendest eine verwendest eine veraltete Version von 2FAGuard. Es können keine Daten geöffnet werden, die bereits mit einer neueren Version der App bearbeitet wurden. Bitte aktualisiere die App, um die Daten zu verwenden.
\ No newline at end of file
diff --git a/Guard/Resources/Strings.en.xaml b/Guard/Resources/Strings.en.xaml
index 6b82e09..8327a2f 100644
--- a/Guard/Resources/Strings.en.xaml
+++ b/Guard/Resources/Strings.en.xaml
@@ -272,4 +272,6 @@
Visual C++ Redistributable not installed
The Microsoft Visual C++ Redistributable 2015-2022 is required to run 2FAGuard. Please install the package to be able to use 2FAGuard. If you have used the 2FAGuard installer or have just installed the package, you may need to restart your device.
Download
+ Outdated app version
+ You are using an outdated version of 2FAGuard. Data that has already been edited with a newer version of the app cannot be opened. Please update the app to use the data.
\ No newline at end of file