mirror of
https://github.com/KeyKeeperApp/KeyKeeper.git
synced 2026-04-17 18:16:28 +03:00
Проверка, что пароли совпадают, и пароль теперь вводится *
This commit is contained in:
@@ -1,28 +1,52 @@
|
||||
<Window xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
x:Class="KeyKeeper.Views.PasswordDialog"
|
||||
x:Class="KeyKeeper.PasswordDialog"
|
||||
Title="Создание хранилища"
|
||||
Width="300"
|
||||
Height="200">
|
||||
Width="350"
|
||||
Height="230">
|
||||
|
||||
<StackPanel Margin="20" VerticalAlignment="Center">
|
||||
|
||||
<TextBlock Text="Введите мастер-пароль:" Margin="0,0,0,5"/>
|
||||
<TextBox x:Name="PasswordBox"
|
||||
Margin="0,0,0,15"/>
|
||||
<TextBlock Text="Set Master Password"
|
||||
FontSize="16"
|
||||
FontWeight="Bold"
|
||||
Margin="0,0,0,15"/>
|
||||
|
||||
<TextBlock Text="Подтвердите пароль:" Margin="0,0,0,5"/>
|
||||
<TextBox x:Name="ConfirmBox"
|
||||
Margin="0,0,0,20"/>
|
||||
<!-- Поле для пароля (звездочки) -->
|
||||
<StackPanel Margin="0,0,0,10">
|
||||
<TextBlock Text="Password:" Margin="0,0,0,5"/>
|
||||
<TextBox x:Name="PasswordBox"
|
||||
PasswordChar="*"
|
||||
Width="250"/>
|
||||
</StackPanel>
|
||||
|
||||
<!-- Поле для подтверждения (звездочки) -->
|
||||
<StackPanel Margin="0,0,0,15">
|
||||
<TextBlock Text="Confirm Password:" Margin="0,0,0,5"/>
|
||||
<TextBox x:Name="ConfirmPasswordBox"
|
||||
PasswordChar="*"
|
||||
Width="250"/>
|
||||
</StackPanel>
|
||||
|
||||
<!-- Сообщение об ошибке -->
|
||||
<TextBlock x:Name="ErrorText"
|
||||
Text="Passwords do not match"
|
||||
Foreground="Red"
|
||||
FontSize="12"
|
||||
Margin="0,0,0,10"
|
||||
IsVisible="False"/>
|
||||
|
||||
<!-- Кнопки -->
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Spacing="10">
|
||||
<Button Content="Отмена"
|
||||
<Button Content="Cancel"
|
||||
Width="80"
|
||||
Click="OnCancelClick"/>
|
||||
Height="30"
|
||||
Click="CancelButton_Click"/>
|
||||
|
||||
<Button Content="Создать"
|
||||
<Button Content="Create"
|
||||
Width="80"
|
||||
Click="OnCreateClick"/>
|
||||
Height="30"
|
||||
Click="CreateButton_Click"/>
|
||||
</StackPanel>
|
||||
|
||||
</StackPanel>
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Avalonia.Interactivity;
|
||||
|
||||
namespace KeyKeeper.Views
|
||||
namespace KeyKeeper
|
||||
{
|
||||
public partial class PasswordDialog : Window
|
||||
{
|
||||
@@ -19,15 +20,47 @@ namespace KeyKeeper.Views
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
}
|
||||
|
||||
private void OnCreateClick(object sender, Avalonia.Interactivity.RoutedEventArgs e)
|
||||
private void CreateButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD>
|
||||
var passwordBox = this.FindControl<TextBox>("PasswordBox");
|
||||
Password = passwordBox?.Text ?? "";
|
||||
var confirmBox = this.FindControl<TextBox>("ConfirmPasswordBox");
|
||||
var errorText = this.FindControl<TextBlock>("ErrorText");
|
||||
|
||||
string password = passwordBox?.Text ?? "";
|
||||
string confirmPassword = confirmBox?.Text ?? "";
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
if (string.IsNullOrEmpty(password) || string.IsNullOrEmpty(confirmPassword))
|
||||
{
|
||||
ShowError("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
||||
return;
|
||||
}
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
if (password != confirmPassword)
|
||||
{
|
||||
ShowError("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
||||
return;
|
||||
}
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
Password = password;
|
||||
Created = true;
|
||||
Close();
|
||||
}
|
||||
|
||||
private void OnCancelClick(object sender, Avalonia.Interactivity.RoutedEventArgs e)
|
||||
private void ShowError(string message)
|
||||
{
|
||||
var errorText = this.FindControl<TextBlock>("ErrorText");
|
||||
if (errorText != null)
|
||||
{
|
||||
errorText.Text = message;
|
||||
errorText.IsVisible = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void CancelButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Created = false;
|
||||
Close();
|
||||
|
||||
@@ -1,17 +1,29 @@
|
||||
<Window xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
x:Class="KeyKeeper.PasswordEntryDialog"
|
||||
Title="Введите пароль"
|
||||
Title="Enter Master Password"
|
||||
Width="300"
|
||||
Height="180">
|
||||
|
||||
<StackPanel Margin="20" VerticalAlignment="Center">
|
||||
<TextBlock Text="Введите мастер-пароль:" Margin="0,0,0,15"/>
|
||||
<TextBox x:Name="PasswordBox" Margin="0,0,0,20"/>
|
||||
<TextBlock Text="Enter master password:" Margin="0,0,0,15"/>
|
||||
|
||||
<!-- Поле для ввода пароля с звездочками -->
|
||||
<TextBox x:Name="PasswordBox"
|
||||
PasswordChar="*"
|
||||
Margin="0,0,0,20"
|
||||
Width="250"/>
|
||||
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Spacing="10">
|
||||
<Button Content="Отмена" Width="80" Click="CancelButton_Click"/>
|
||||
<Button Content="Открыть" Width="80" Click="OpenButton_Click"/>
|
||||
<Button Content="Cancel"
|
||||
Width="80"
|
||||
Height="30"
|
||||
Click="CancelButton_Click"/>
|
||||
|
||||
<Button Content="Open"
|
||||
Width="80"
|
||||
Height="30"
|
||||
Click="OpenButton_Click"/>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user