Skip to content

Commit

Permalink
chore: show info when MDM settings have been set
Browse files Browse the repository at this point in the history
  • Loading branch information
jp-weber committed May 31, 2024
1 parent 247534c commit 7a63e3f
Show file tree
Hide file tree
Showing 38 changed files with 541 additions and 250 deletions.
8 changes: 6 additions & 2 deletions Project2FA.Core/Services/JSON/NewtonsoftJSONService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,15 @@ public string SerializeEncrypt(string key, byte[] initVectorArray, object value,
{
byteArrayKey = CryptoService.CreateByteArrayKeyV1(key);
}
else
else if (encryptionVersion == 2)
{
byteArrayKey = CryptoService.CreateByteArrayKeyV2(key);
}

else
{
byteArrayKey = CryptoService.CreateByteArrayKeyV2(key, 80000);
}

var serializer = new JsonSerializer
{
ContractResolver = _encryptionFactory.GetContractResolver()
Expand Down
5 changes: 1 addition & 4 deletions Project2FA.Shared/Services/DataService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -810,10 +810,7 @@ await Task.Run(async () => {
#if WINDOWS_UWP
TrackingManager.TrackExceptionCatched(nameof(WriteLocalDatafile), exc);
#endif
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
HandleWriteError(datafile,fileName,folder);
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed

await HandleWriteError(datafile,fileName,folder);
}
}

Expand Down
12 changes: 7 additions & 5 deletions Project2FA.Shared/Services/Logging/LoggingService.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using Project2FA.Core;

using Project2FA.Core;
using Project2FA.Core.Services.JSON;
using Project2FA.Services.Enums;
using System;
using System.Threading.Tasks;
Expand Down Expand Up @@ -75,11 +77,11 @@ public async Task LogException(Exception exc)
/// <returns></returns>
private async Task WriteExceptionLog(Exception exc, StorageFile file)
{
#if WINDOWS_UWP
await FileIO.AppendTextAsync(file, _timeStemp + "uptime " + Microsoft.Toolkit.Uwp.Helpers.SystemInformation.Instance.AppUptime + "\n");
#endif
await FileIO.AppendTextAsync(file, _timeStemp + exc.Source + " - " + exc.Message + "\n");
if (exc.InnerException != null)
{
await FileIO.AppendTextAsync(file, "InnerException - " + exc.InnerException.ToString() + "\n");
}
await FileIO.AppendTextAsync(file, "Log - " + exc.ToString() + "\n");
}
}
}
10 changes: 9 additions & 1 deletion Project2FA.Shared/Services/Parser/Project2FAParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,19 +140,27 @@ public List<KeyValuePair<string, string>> ParseCmdStr(string cmdStr)
//get only the parameter string
cmdStr = cmdStr.Remove(0, match.Groups[0].Length + 1); //remove //twofastauth://CATEGORY/set?
string isScreenCaptureEnabled;
string startLogFileCmd;
string collectionVar;

if (!string.IsNullOrEmpty(cmdStr))
{
//create collection of the parameter values
System.Collections.Specialized.NameValueCollection nameValueCollection = HttpUtility.ParseQueryString(cmdStr);

collectionVar = nameValueCollection["IsScreenCaptureEnabled"];
collectionVar = nameValueCollection[nameof(isScreenCaptureEnabled)];
if (!string.IsNullOrEmpty(collectionVar))
{
isScreenCaptureEnabled = collectionVar;
cmdParams.Add(new KeyValuePair<string, string>(nameof(isScreenCaptureEnabled), isScreenCaptureEnabled));
}

collectionVar = nameValueCollection[nameof(startLogFileCmd)];
if (!string.IsNullOrEmpty(collectionVar))
{
startLogFileCmd = collectionVar;
cmdParams.Add(new KeyValuePair<string, string>(nameof(startLogFileCmd), startLogFileCmd));
}
}
}
//else not definied
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace Project2FA.Services.Enums
namespace Project2FA.Services.Enums
{
public enum LoggingPreferEnum
{
Expand Down
6 changes: 6 additions & 0 deletions Project2FA.Shared/Services/SettingsService/SettingsService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ public bool UseRoundCorner
}
}

public bool ShowAvailableProFeatures
{
get => _helper.SafeRead(nameof(ShowAvailableProFeatures), true);
set => _helper.TryWrite(nameof(ShowAvailableProFeatures), value);
}

public bool AutoLogoutMinutesIsMDMManaged
{
get => _helper.SafeRead(nameof(AutoLogoutMinutesIsMDMManaged), false);
Expand Down
14 changes: 13 additions & 1 deletion Project2FA.Shared/Strings/de/Resources.resw
Original file line number Diff line number Diff line change
Expand Up @@ -1331,6 +1331,18 @@ Derzeit verfügbar:
<value>Konto bearbeiten</value>
</data>
<data name="AddAccountContentDialogNoCaptureContentError" xml:space="preserve">
<value>Es wurde kein Fenster zum einlesen eines QR-Codes ausgewählt.</value>
<value>Es wurde kein Fenster zum Einlesen eines QR-Codes ausgewählt.</value>
</data>
<data name="LoginPageIOSBiometricReason" xml:space="preserve">
<value>Mit der Nutzung der Biometrie wird die Anmeldung ohne Passwort umgesetzt.</value>
</data>
<data name="SettingsAppShowAvailableProFeatures.Header" xml:space="preserve">
<value>Anzeige von Pro-Funktionen</value>
</data>
<data name="SettingsAppShowAvailableProFeaturessDesc.Text" xml:space="preserve">
<value>Mit der Einstellung kann die Sichtbarkeit der Platzhalter von Pro-Funktionen aus- oder eingeschaltet werden.</value>
</data>
<data name="SettingsMDMInfo.Text" xml:space="preserve">
<value>*Einige Einstellungen werden von Ihrer Organisation verwaltet.</value>
</data>
</root>
13 changes: 12 additions & 1 deletion Project2FA.Shared/Strings/en/Resources.generated.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2031,6 +2031,16 @@ public static string AddAccountContentDialogNoCaptureContentError
}
#endregion

#region LoginPageIOSBiometricReason
public static string LoginPageIOSBiometricReason
{
get
{
return _resourceLoader.GetString("LoginPageIOSBiometricReason");
}
}
#endregion

}

[global::System.CodeDom.Compiler.GeneratedCodeAttribute("DotNetPlus.ReswPlus", "2.1.3")]
Expand Down Expand Up @@ -2194,7 +2204,8 @@ public enum KeyEnum
LoginPageWindowsHelloError,
EditAccountContentDialogAccountCategoryInfoText,
EditAccountPageTitle,
AddAccountContentDialogNoCaptureContentError
AddAccountContentDialogNoCaptureContentError,
LoginPageIOSBiometricReason
}

private static ResourceLoader _resourceLoader;
Expand Down
12 changes: 12 additions & 0 deletions Project2FA.Shared/Strings/en/Resources.resw
Original file line number Diff line number Diff line change
Expand Up @@ -1330,4 +1330,16 @@ Currently available:
<data name="AddAccountContentDialogNoCaptureContentError" xml:space="preserve">
<value>No window for scanning a QR code has been selected.</value>
</data>
<data name="LoginPageIOSBiometricReason" xml:space="preserve">
<value>With the use of biometrics, login is implemented without a password.</value>
</data>
<data name="SettingsAppShowAvailableProFeatures.Header" xml:space="preserve">
<value>Display of Pro functions</value>
</data>
<data name="SettingsAppShowAvailableProFeaturessDesc.Text" xml:space="preserve">
<value>This setting can be used to switch the visibility of placeholders for Pro functions on or off.</value>
</data>
<data name="SettingsMDMInfo.Text" xml:space="preserve">
<value>*Some settings are managed by your organisation.</value>
</data>
</root>
12 changes: 12 additions & 0 deletions Project2FA.Shared/Utils/ErrorDialogs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,18 @@ async void Dialog_Closed(ContentDialog sender, ContentDialogClosedEventArgs args
}
}

public async static Task ShowLogNotFound()
{
var dialog = new ContentDialog
{
Title = Strings.Resources.SettingsPageNoLogDialogTitle,
Content = Strings.Resources.SettingsPageNoLogDialogContent,
PrimaryButtonText = Strings.Resources.Confirm
};

await App.Current.Container.Resolve<IDialogService>().ShowDialogAsync(dialog, new DialogParameters());
}

internal static Task WritingFatalRestoreError()
{
// TODO generate
Expand Down
18 changes: 12 additions & 6 deletions Project2FA.Shared/ViewModels/AccountCodePageViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@
using Project2FA.Core.Utils;
using Project2FA.Services.Logging;




#if WINDOWS_UWP
using Project2FA.UWP;
using Project2FA.UWP.Views;
Expand Down Expand Up @@ -281,8 +278,6 @@ private async Task StartTOTPLogic()
}
}



_dispatcherTOTPTimer.Tick -= TOTPTimer;
_dispatcherTOTPTimer.Tick += TOTPTimer;
_dispatcherTOTPTimer.Start(); // the event for the set of seconds and calculating the totp code
Expand Down Expand Up @@ -559,6 +554,10 @@ public void Initialize(INavigationParameters parameters)
TwoFADataService.ACVCollection.Filter = null;
}

#if __ANDROID__ || __IOS__
Messenger.Send(new Project2FA.UNO.MauiControls.ControlDisposeMessage(true));
#endif

//Start the app logic
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
StartTOTPLogic();
Expand Down Expand Up @@ -674,7 +673,14 @@ public void SendCategoryFilterUpdatate()
Messenger.Send(new CategoriesChangedMessage(true));
}
#endif
#region Getter_Setter
#region Getter_Setter

#if WINDOWS_UWP
public bool ShowAvailableProFeatures
{
get => SettingsService.Instance.ShowAvailableProFeatures;
}
#endif
public bool IsAccountDeleted => TwoFADataService.TempDeletedTFAModel != null;

public bool IsAccountNotDeleted => TwoFADataService.TempDeletedTFAModel == null;
Expand Down
9 changes: 5 additions & 4 deletions Project2FA.Shared/ViewModels/AddAccountCameraPageViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,11 @@ public void Initialize(INavigationParameters parameters)

public bool CanNavigate(INavigationParameters parameters)
{
if (!_foundAccount)
{
Messenger.Send(new ControlDisposeMessage(true));
}
//if (!_foundAccount)
//{
// Messenger.Send(new ControlDisposeMessage(true));
//}
Messenger.Send(new ControlDisposeMessage(true));
return true;
}
}
Expand Down
23 changes: 11 additions & 12 deletions Project2FA.Shared/ViewModels/Base/AddAccountViewModelBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,11 @@
using UNOversal.Logging;
using UNOversal.Services.Serialization;
using Project2FA.Services.Parser;
using UNOversal.Services.File;
using Windows.Media;
using System.Threading.Tasks;
using Windows.Storage;
using Windows.Storage.Streams;
using System.IO;
using Project2FA.Helpers;
using Project2FA.Services;
using Windows.UI.Core;
using Windows.Graphics.Imaging;
using Windows.UI.Popups;
using Project2FA.Core.ProtoModels;
Expand All @@ -35,8 +31,7 @@
using CommunityToolkit.WinUI.Helpers;
using Project2FA.Services.Logging;
using Prism.Ioc;


using UNOversal.Navigation;



Expand All @@ -60,6 +55,7 @@
using Microsoft.UI.Xaml.Data;
using WindowActivatedEventArgs = Microsoft.UI.Xaml.WindowActivatedEventArgs;
using WinUIWindow = Microsoft.UI.Xaml.Window;
using Project2FA.UNO.Views;
#endif

namespace Project2FA.ViewModels
Expand Down Expand Up @@ -200,6 +196,9 @@ private async Task PrimaryButtonCommandTask()
{
DataService.Instance.Collection.Add(Model);
}
#if __ANDROID__ || _IOS__
await App.ShellPageInstance.ViewModel.NavigationService.NavigateAsync("/" + nameof(AccountCodePage));
#endif
}

private async Task SecondayButtonCommandTask()
Expand Down Expand Up @@ -231,8 +230,6 @@ private async Task ScanScreenQRCode()
//_item = item;
// Stop the previous capture if we had one.
StopWindowScreenCapture();
// We'll define this method later in the document.
//StartCaptureInternal(item);

_framePool = Direct3D11CaptureFramePool.Create(
_canvasDevice, // D3D device
Expand Down Expand Up @@ -573,8 +570,6 @@ private Task<bool> ParseMigrationQRCode()
{
return Task.FromResult(false);
}


}

/// <summary>
Expand Down Expand Up @@ -1092,6 +1087,7 @@ public bool CameraSuccessfullyLoaded
get => _cameraSuccessfullyLoaded;
set => SetProperty(ref _cameraSuccessfullyLoaded, value);
}
#endregion

public void Dispose()
{
Expand All @@ -1103,11 +1099,14 @@ protected virtual void Dispose(bool disposing)
{
if (disposing)
{

#if WINDOWS_UWP
_mediaPlayer?.Dispose();
_cameraHelper?.Dispose();
_framePool?.Dispose();
_canvasDevice?.Dispose();
_session?.Dispose();
#endif
}
}
#endregion
}
}
Loading

0 comments on commit 7a63e3f

Please sign in to comment.