Skip to content

Commit 577218b

Browse files
committed
Support saving session credentials on MAUI
1 parent 5133e1f commit 577218b

9 files changed

Lines changed: 57 additions & 14 deletions

File tree

src/Platforms/SecureFolderFS.Maui/Platforms/Android/ViewModels/AndroidBiometricViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
using Java.Security;
66
using OwlCore.Storage;
77
using SecureFolderFS.Core;
8-
using SecureFolderFS.Core.Cryptography.SecureStore;
98
using SecureFolderFS.Maui.AppModels;
109
using SecureFolderFS.Maui.Platforms.Android.Helpers;
1110
using SecureFolderFS.Sdk.Enums;
1211
using SecureFolderFS.Sdk.Extensions;
1312
using SecureFolderFS.Sdk.ViewModels.Controls.Authentication;
1413
using SecureFolderFS.Shared.ComponentModel;
1514
using SecureFolderFS.Shared.Models;
15+
using SecureFolderFS.Shared.SecureStore;
1616

1717
namespace SecureFolderFS.Maui.Platforms.Android.ViewModels
1818
{

src/Platforms/SecureFolderFS.Maui/Platforms/iOS/ViewModels/IOSBiometricCreationViewModel.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
using System.Security.Cryptography;
22
using OwlCore.Storage;
33
using SecureFolderFS.Core.Cryptography;
4-
using SecureFolderFS.Core.Cryptography.Extensions;
5-
using SecureFolderFS.Core.Cryptography.SecureStore;
64
using SecureFolderFS.Core.DataModels;
75
using SecureFolderFS.Core.VaultAccess;
86
using SecureFolderFS.Sdk.EventArguments;
97
using SecureFolderFS.Shared.Extensions;
108
using SecureFolderFS.Shared.Models;
9+
using SecureFolderFS.Shared.SecureStore;
1110

1211
namespace SecureFolderFS.Maui.Platforms.iOS.ViewModels
1312
{

src/Platforms/SecureFolderFS.Maui/TemplateSelectors/LoginTemplateSelector.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ internal sealed class LoginTemplateSelector : DataTemplateSelector
1616

1717
public DataTemplate? KeyFileTemplate { get; set; }
1818

19+
public DataTemplate? PersistedAuthenticationTemplate { get; set; }
20+
1921
public DataTemplate? ErrorTemplate { get; set; }
2022

2123
public DataTemplate? UnsupportedTemplate { get; set; }
@@ -44,6 +46,7 @@ internal sealed class LoginTemplateSelector : DataTemplateSelector
4446
#elif IOS
4547
IOSBiometricLoginViewModel => IOSBiometricsTemplate,
4648
#endif
49+
PersistedAuthenticationViewModel => PersistedAuthenticationTemplate,
4750
ErrorViewModel => ErrorTemplate,
4851
UnsupportedViewModel => UnsupportedTemplate,
4952
_ => null

src/Platforms/SecureFolderFS.Maui/UserControls/LoginControl.xaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,28 @@
100100
</ContentView>
101101
</DataTemplate>
102102

103+
<!-- Persisted Template -->
104+
<DataTemplate x:Key="PersistedAuthenticationTemplate" x:DataType="vm2:PersistedAuthenticationViewModel">
105+
<ContentView>
106+
<VerticalStackLayout Spacing="16">
107+
<!-- Title -->
108+
<Label
109+
HorizontalOptions="Center"
110+
Opacity="0.8"
111+
Text="{l:ResourceString Rid=CredentialsHaveBeenSaved}" />
112+
113+
<!-- Unlock button -->
114+
<local:ActivityButton
115+
ButtonStyle="{StaticResource AccentButtonStyle}"
116+
Command="{Binding ProvideCredentialsCommand}"
117+
FontAttributes="Bold"
118+
HorizontalOptions="Fill"
119+
IsProgressing="{Binding ProvideCredentialsCommand.IsRunning, Mode=OneWay}"
120+
Text="{l:ResourceString Rid=Unlock}" />
121+
</VerticalStackLayout>
122+
</ContentView>
123+
</DataTemplate>
124+
103125
<!-- Error Template -->
104126
<DataTemplate x:Key="ErrorTemplate" x:DataType="vm2:ErrorViewModel">
105127
<ContentView>
@@ -126,6 +148,7 @@
126148
ErrorTemplate="{StaticResource ErrorTemplate}"
127149
KeyFileTemplate="{StaticResource KeyFileTemplate}"
128150
PasswordTemplate="{StaticResource PasswordTemplate}"
151+
PersistedAuthenticationTemplate="{StaticResource PersistedAuthenticationTemplate}"
129152
UnsupportedTemplate="{StaticResource UnsupportedTemplate}" />
130153
</local:ContentPresentation.TemplateSelector>
131154
</local:ContentPresentation>

src/Platforms/SecureFolderFS.Maui/Views/Vault/LoginPage.xaml

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,24 @@
7575
<uc:VaultLocatorControl.LoginView>
7676
<VerticalStackLayout IsVisible="{Binding ViewModel.IsProgressing, Mode=OneWay, Converter={StaticResource BoolInvertConverter}}" Spacing="8">
7777
<uc:LoginControl CurrentViewModel="{Binding ViewModel.LoginViewModel.CurrentViewModel, Mode=OneWay}" ProvideContinuationButton="True" />
78-
<Button
79-
Command="{Binding ViewModel.LoginViewModel.RecoverAccessCommand}"
80-
HorizontalOptions="{OnPlatform Android={LayoutOptions Alignment=Fill},
81-
iOS={LayoutOptions Alignment=Center}}"
82-
IsVisible="{Binding ViewModel.LoginViewModel.CurrentViewModel, Mode=OneWay, Converter={StaticResource TypeNameBoolConverter}, ConverterParameter='MigrationViewModel,ErrorViewModel|invert'}"
83-
Style="{OnPlatform Android={StaticResource TransparentButtonStyle},
84-
iOS={StaticResource NoBackgroundButtonStyle}}"
85-
Text="{l:ResourceString Rid=RecoverAccess}" />
78+
<VerticalStackLayout>
79+
<Button
80+
Command="{Binding ViewModel.LoginViewModel.DiscardSavedCredentialsCommand}"
81+
HorizontalOptions="{OnPlatform Android={LayoutOptions Alignment=Fill},
82+
iOS={LayoutOptions Alignment=Center}}"
83+
IsVisible="{Binding ViewModel.LoginViewModel.AreCredentialsSaved, Mode=OneWay}"
84+
Style="{OnPlatform Android={StaticResource TransparentButtonStyle},
85+
iOS={StaticResource NoBackgroundButtonStyle}}"
86+
Text="{l:ResourceString Rid=DiscardSavedCredentials}" />
87+
<Button
88+
Command="{Binding ViewModel.LoginViewModel.RecoverAccessCommand}"
89+
HorizontalOptions="{OnPlatform Android={LayoutOptions Alignment=Fill},
90+
iOS={LayoutOptions Alignment=Center}}"
91+
IsVisible="{Binding ViewModel.LoginViewModel.CurrentViewModel, Mode=OneWay, Converter={StaticResource TypeNameBoolConverter}, ConverterParameter='MigrationViewModel,ErrorViewModel|invert'}"
92+
Style="{OnPlatform Android={StaticResource TransparentButtonStyle},
93+
iOS={StaticResource NoBackgroundButtonStyle}}"
94+
Text="{l:ResourceString Rid=RecoverAccess}" />
95+
</VerticalStackLayout>
8696
</VerticalStackLayout>
8797
</uc:VaultLocatorControl.LoginView>
8898
</uc:VaultLocatorControl>

src/Platforms/SecureFolderFS.UI/Strings/en-US/Resources.resx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1448,4 +1448,10 @@
14481448
<data name="FileModified" xml:space="preserve">
14491449
<value>Modified</value>
14501450
</data>
1451+
<data name="CredentialsHaveBeenSaved" xml:space="preserve">
1452+
<value>Credentials have been saved for this vault</value>
1453+
</data>
1454+
<data name="DiscardSavedCredentials" xml:space="preserve">
1455+
<value>Discard saved credentials</value>
1456+
</data>
14511457
</root>

src/Platforms/SecureFolderFS.Uno/UserControls/InterfaceRoot/VaultPreviewRootControl.xaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,12 @@
5151
<StackPanel VerticalAlignment="Center" Spacing="8">
5252
<uc:LoginControl CurrentViewModel="{x:Bind ViewModel.LoginViewModel.CurrentViewModel, Mode=OneWay}" ProvideContinuationButton="True" />
5353
<uc:LoginOptions
54+
AreCredentialsSaved="{x:Bind ViewModel.LoginViewModel.AreCredentialsSaved, Mode=OneWay}"
55+
DiscardSavedCredentialsCommand="{x:Bind ViewModel.LoginViewModel.DiscardSavedCredentialsCommand, Mode=OneWay}"
5456
IsReadOnly="{x:Bind ViewModel.IsReadOnly, Mode=TwoWay}"
5557
RecoverAccessCommand="{x:Bind ViewModel.RecoverAccessCommand, Mode=OneWay}"
5658
RestartLoginCommand="{x:Bind ViewModel.LoginViewModel.RestartLoginProcessCommand, Mode=OneWay}"
57-
ShouldSaveCredentials="{x:Bind ViewModel.ShouldSaveCredentials, Mode=TwoWay}"
59+
ShouldSaveCredentials="{x:Bind ViewModel.LoginViewModel.ShouldSaveCredentials, Mode=TwoWay}"
5860
Visibility="{x:Bind ViewModel.LoginViewModel.CurrentViewModel, Mode=OneWay, Converter={StaticResource TypeNameVisibilityConverter}, ConverterParameter='MigrationViewModel,ErrorViewModel|invert'}" />
5961
</StackPanel>
6062
</StackPanel>

src/Platforms/SecureFolderFS.Uno/UserControls/LoginControl.xaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,8 @@
186186
<!-- Persisted Template -->
187187
<DataTemplate x:Key="PersistedAuthenticationTemplate" x:DataType="vm5:PersistedAuthenticationViewModel">
188188
<StackPanel Spacing="16">
189-
<TextBlock HorizontalAlignment="Center" Text="Credentials have been saved for this vault" />
189+
<!-- Title -->
190+
<TextBlock HorizontalAlignment="Center" Text="{l:ResourceString Rid=CredentialsHaveBeenSaved}" />
190191

191192
<!-- Continue -->
192193
<Button

src/Sdk/SecureFolderFS.Sdk/ViewModels/Views/Root/VaultPreviewViewModel.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ public sealed partial class VaultPreviewViewModel : ObservableObject, IAsyncInit
3030
[ObservableProperty] private UnlockedVaultViewModel? _UnlockedVaultViewModel;
3131
[ObservableProperty] private LoginViewModel? _LoginViewModel;
3232
[ObservableProperty] private VaultViewModel _VaultViewModel;
33-
[ObservableProperty] private bool _ShouldSaveCredentials;
3433
[ObservableProperty] private bool _IsReadOnly;
3534

3635
public VaultPreviewViewModel(VaultViewModel vaultViewModel, INavigationService vaultNavigation)

0 commit comments

Comments
 (0)