ADDED another error message and fixed the height of my new entry window. and added input sanitization for new entries
This commit is contained in:
parent
ad25e8c849
commit
f86465ff71
@ -21,4 +21,23 @@ public partial class InputSanitizer
|
|||||||
if (string.IsNullOrEmpty(username) || username.Length < 4) return false;
|
if (string.IsNullOrEmpty(username) || username.Length < 4) return false;
|
||||||
else return true;
|
else return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//NewEntry - Name Check
|
||||||
|
public static bool EntryName(string name)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(name)) return false;
|
||||||
|
else return true;
|
||||||
|
}
|
||||||
|
//NewEntry - user/mailcheck
|
||||||
|
public static bool Userormail(string usermail)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(usermail)) return false;
|
||||||
|
else return true;
|
||||||
|
}
|
||||||
|
//NewEntry - password check
|
||||||
|
public static bool Password(string pass)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(pass) || pass.Length < 6) return false;
|
||||||
|
else return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
57
Project.View/EntryErrorPopup/EntryErrorPopup.axaml
Normal file
57
Project.View/EntryErrorPopup/EntryErrorPopup.axaml
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
<Window
|
||||||
|
SizeToContent="Height"
|
||||||
|
Title="WARNING"
|
||||||
|
Width="500"
|
||||||
|
WindowStartupLocation="CenterOwner"
|
||||||
|
x:Class="Project.View.EntryErrorPopUp"
|
||||||
|
xmlns="https://github.com/avaloniaui"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||||
|
|
||||||
|
<Window.Styles>
|
||||||
|
<Style Selector="TextBlock">
|
||||||
|
<Setter Property="HorizontalAlignment" Value="Center" />
|
||||||
|
<Setter Property="FontSize" Value="14" />
|
||||||
|
<Setter Property="Foreground" Value="Gray" />
|
||||||
|
<Setter Property="TextWrapping" Value="Wrap" />
|
||||||
|
<Setter Property="Margin" Value="0,5" />
|
||||||
|
</Style>
|
||||||
|
<Style Selector="Button">
|
||||||
|
<Setter Property="Width" Value="120" />
|
||||||
|
<Setter Property="Height" Value="40" />
|
||||||
|
<Setter Property="CornerRadius" Value="20" />
|
||||||
|
<Setter Property="Margin" Value="0,15,0,0" />
|
||||||
|
<Setter Property="HorizontalAlignment" Value="Center" />
|
||||||
|
<Setter Property="HorizontalContentAlignment" Value="Center" />
|
||||||
|
<Setter Property="VerticalContentAlignment" Value="Center" />
|
||||||
|
<Setter Property="Background" Value="#4CAF50" />
|
||||||
|
<Setter Property="Foreground" Value="White" />
|
||||||
|
</Style>
|
||||||
|
</Window.Styles>
|
||||||
|
|
||||||
|
<Grid Background="#F5F5F5">
|
||||||
|
<Border
|
||||||
|
Background="White"
|
||||||
|
BoxShadow="0 4 8 0 #40000000"
|
||||||
|
CornerRadius="8"
|
||||||
|
Margin="15">
|
||||||
|
|
||||||
|
<ScrollViewer>
|
||||||
|
<StackPanel Margin="20" MaxWidth="450">
|
||||||
|
<TextBlock
|
||||||
|
FontSize="24"
|
||||||
|
FontWeight="Bold"
|
||||||
|
Margin="0,0,0,15"
|
||||||
|
Text="⚠️ Warning" />
|
||||||
|
<TextBlock Text="Please fill out all the boxes except note and/or URL." />
|
||||||
|
<TextBlock Text="Your password should be at least 6 characters long." />
|
||||||
|
<TextBlock Text="I recommend a password length of 12 characters or more." />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
Click="EntryError_Click"
|
||||||
|
Content="OK"
|
||||||
|
Margin="0,15,0,5" />
|
||||||
|
</StackPanel>
|
||||||
|
</ScrollViewer>
|
||||||
|
</Border>
|
||||||
|
</Grid>
|
||||||
|
</Window>
|
||||||
22
Project.View/EntryErrorPopup/EntryErrorPopup.axaml.cs
Normal file
22
Project.View/EntryErrorPopup/EntryErrorPopup.axaml.cs
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
using System;
|
||||||
|
using Avalonia.Controls;
|
||||||
|
using Avalonia.Interactivity;
|
||||||
|
using Avalonia.Media;
|
||||||
|
using Project.Controller;
|
||||||
|
using Project.Model;
|
||||||
|
using Project.Persistence;
|
||||||
|
namespace Project.View;
|
||||||
|
|
||||||
|
public partial class EntryErrorPopUp : Window
|
||||||
|
|
||||||
|
{
|
||||||
|
public EntryErrorPopUp()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void EntryError_Click(object? sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,3 +1,4 @@
|
|||||||
|
using System;
|
||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
using Avalonia.Interactivity;
|
using Avalonia.Interactivity;
|
||||||
using Avalonia.Media;
|
using Avalonia.Media;
|
||||||
@ -11,6 +12,7 @@ public partial class NewEntry : Window
|
|||||||
public NewEntry()
|
public NewEntry()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
this.SizeToContent = SizeToContent.Height;
|
||||||
}
|
}
|
||||||
|
|
||||||
public NewEntry(AppController controller)
|
public NewEntry(AppController controller)
|
||||||
@ -30,21 +32,35 @@ public partial class NewEntry : Window
|
|||||||
string? url = URLBox.Text;
|
string? url = URLBox.Text;
|
||||||
string? pass = PassBox.Text;
|
string? pass = PassBox.Text;
|
||||||
string? note = NoteBox.Text;
|
string? note = NoteBox.Text;
|
||||||
AppController.NewEntrySave(name, username, url, pass, note);
|
if (InputSanitizer.EntryName(name) && InputSanitizer.Password(pass) && InputSanitizer.Userormail(username))
|
||||||
var newMenuView = new MenuView();
|
{
|
||||||
newMenuView.AfterSavingNewEntry();
|
AppController.NewEntrySave(name, username, url, pass, note);
|
||||||
Close();
|
var newMenuView = new MenuView();
|
||||||
|
newMenuView.AfterSavingNewEntry();
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var newPopUp = new EntryErrorPopUp();
|
||||||
|
NameBox.Text = string.Empty;
|
||||||
|
UsernameMailBox.Text = string.Empty;
|
||||||
|
URLBox.Text = String.Empty;
|
||||||
|
PassBox.Text = String.Empty;
|
||||||
|
NoteBox.Text = String.Empty;
|
||||||
|
newPopUp.Show();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void NewEntry_ShowPW_Click(object? sender, RoutedEventArgs e)
|
private void NewEntry_ShowPW_Click(object? sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
if (NewentryPW.PasswordChar == '*')
|
if (NewentryPW.PasswordChar == '•')
|
||||||
{
|
{
|
||||||
NewentryPW.PasswordChar = '\0';
|
NewentryPW.PasswordChar = '\0';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
NewentryPW.PasswordChar = '*';
|
NewentryPW.PasswordChar = '•';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -45,7 +45,8 @@
|
|||||||
<TextBlock Text="One or more entries are wrong or missing." />
|
<TextBlock Text="One or more entries are wrong or missing." />
|
||||||
<TextBlock Text="All boxes must be filled in." />
|
<TextBlock Text="All boxes must be filled in." />
|
||||||
<TextBlock Text="Your username needs to be at least 4 characters." />
|
<TextBlock Text="Your username needs to be at least 4 characters." />
|
||||||
<TextBlock Text="Your password needs to be at least 8 characters." />
|
<TextBlock Text="Your password needs to be at least 6 characters." />
|
||||||
|
<TextBlock Text="I recommend a password length of 12 characters or more." />
|
||||||
<TextBlock Text="Make sure your e-mail is correct." />
|
<TextBlock Text="Make sure your e-mail is correct." />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
|
|||||||
@ -40,6 +40,10 @@
|
|||||||
<DependentUpon>PopUp.axaml</DependentUpon>
|
<DependentUpon>PopUp.axaml</DependentUpon>
|
||||||
<SubType>Code</SubType>
|
<SubType>Code</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Update="EntryErrorPopup\EntryErrorPopup.axaml.cs">
|
||||||
|
<DependentUpon>EntryErrorPopup.axaml</DependentUpon>
|
||||||
|
<SubType>Code</SubType>
|
||||||
|
</Compile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user