mirror of
https://github.com/KeyKeeperApp/KeyKeeper.git
synced 2026-05-13 11:56:30 +03:00
make unlocking work, no exception handling yet
This commit is contained in:
@@ -56,10 +56,12 @@
|
|||||||
HorizontalAlignment="Center"
|
HorizontalAlignment="Center"
|
||||||
VerticalAlignment="Center">
|
VerticalAlignment="Center">
|
||||||
<TextBox x:Name="UnlockPasswordEdit"
|
<TextBox x:Name="UnlockPasswordEdit"
|
||||||
|
Text="{Binding UnlockPassword, Mode=TwoWay}"
|
||||||
PasswordChar="*"
|
PasswordChar="*"
|
||||||
Width="450" />
|
Width="450" />
|
||||||
|
|
||||||
<Button x:Name="UnlockButton"
|
<Button x:Name="UnlockButton"
|
||||||
|
Command="{Binding TryUnlock}"
|
||||||
HorizontalAlignment="Center"
|
HorizontalAlignment="Center"
|
||||||
Foreground="Black"
|
Foreground="Black"
|
||||||
Content="Unlock!" />
|
Content="Unlock!" />
|
||||||
|
|||||||
@@ -1,13 +1,44 @@
|
|||||||
|
using System;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using CommunityToolkit.Mvvm.Input;
|
||||||
using KeyKeeper.PasswordStore;
|
using KeyKeeper.PasswordStore;
|
||||||
|
using KeyKeeper.PasswordStore.Crypto;
|
||||||
|
|
||||||
namespace KeyKeeper.ViewModels;
|
namespace KeyKeeper.ViewModels;
|
||||||
|
|
||||||
public class LockedRepositoryViewModel : ViewModelBase
|
public partial class LockedRepositoryViewModel : ViewModelBase
|
||||||
{
|
{
|
||||||
|
RepositoryWindowViewModel parent;
|
||||||
private IPassStore passStore;
|
private IPassStore passStore;
|
||||||
|
private string password;
|
||||||
|
|
||||||
public LockedRepositoryViewModel(IPassStore store)
|
public LockedRepositoryViewModel(IPassStore store, RepositoryWindowViewModel parent)
|
||||||
{
|
{
|
||||||
passStore = store;
|
passStore = store;
|
||||||
|
this.parent = parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string UnlockPassword
|
||||||
|
{
|
||||||
|
get => password;
|
||||||
|
set { password = value; OnPropertyChanged(nameof(UnlockPassword)); }
|
||||||
|
}
|
||||||
|
|
||||||
|
[RelayCommand]
|
||||||
|
public void TryUnlock()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
passStore.Unlock(new CompositeKey(UnlockPassword, null));
|
||||||
|
parent.UpdateLockStatus();
|
||||||
|
} catch (PassStoreFileException e)
|
||||||
|
{
|
||||||
|
// TODO
|
||||||
|
Console.WriteLine("pass store file exception: " + e.Message);
|
||||||
|
} catch (Exception e)
|
||||||
|
{
|
||||||
|
// TODO
|
||||||
|
Console.WriteLine(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,8 +1,11 @@
|
|||||||
|
using System;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using CommunityToolkit.Mvvm.Input;
|
||||||
using KeyKeeper.PasswordStore;
|
using KeyKeeper.PasswordStore;
|
||||||
|
|
||||||
namespace KeyKeeper.ViewModels;
|
namespace KeyKeeper.ViewModels;
|
||||||
|
|
||||||
public class RepositoryWindowViewModel : ViewModelBase
|
public partial class RepositoryWindowViewModel : ViewModelBase
|
||||||
{
|
{
|
||||||
private object currentPage;
|
private object currentPage;
|
||||||
private IPassStore passStore;
|
private IPassStore passStore;
|
||||||
@@ -19,7 +22,7 @@ public class RepositoryWindowViewModel : ViewModelBase
|
|||||||
UpdateLockStatus();
|
UpdateLockStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateLockStatus()
|
public void UpdateLockStatus()
|
||||||
{
|
{
|
||||||
if ((currentPage == null || currentPage is LockedRepositoryViewModel) && !passStore.Locked)
|
if ((currentPage == null || currentPage is LockedRepositoryViewModel) && !passStore.Locked)
|
||||||
SwitchToUnlocked();
|
SwitchToUnlocked();
|
||||||
@@ -29,11 +32,11 @@ public class RepositoryWindowViewModel : ViewModelBase
|
|||||||
|
|
||||||
private void SwitchToUnlocked()
|
private void SwitchToUnlocked()
|
||||||
{
|
{
|
||||||
currentPage = new UnlockedRepositoryViewModel(passStore);
|
CurrentPage = new UnlockedRepositoryViewModel(passStore);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SwitchToLocked()
|
private void SwitchToLocked()
|
||||||
{
|
{
|
||||||
currentPage = new LockedRepositoryViewModel(passStore);
|
CurrentPage = new LockedRepositoryViewModel(passStore, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user