diff --git a/Project.Controller/AppController.cs b/Project.Controller/AppController.cs index c656947..6b23eee 100644 --- a/Project.Controller/AppController.cs +++ b/Project.Controller/AppController.cs @@ -2,7 +2,7 @@ using Project.Model; namespace Project.Controller; -public class AppController +public partial class AppController { public static void NewLoginSave(string username, string password, string email) { diff --git a/Project.Controller/InputSanitizer.cs b/Project.Controller/InputSanitizer.cs new file mode 100644 index 0000000..4c321d1 --- /dev/null +++ b/Project.Controller/InputSanitizer.cs @@ -0,0 +1,23 @@ +namespace Project.Controller; + +public class InputSanitizer +{ + public static bool MasterLoginPasswordBool(string password) + { + if (string.IsNullOrEmpty(password) || password.Length < 6) return false; + else return true; + } + + public static bool MasterLoginEmailBool(string email) + { + if (string.IsNullOrEmpty(email)) return false; + if (email.Contains('@') && email.Length > 6) return true; + else return false; + } + + public static bool MasterLoginNameBool(string username) + { + if (string.IsNullOrEmpty(username) || username.Length < 4) return false; + else return true; + } +} \ No newline at end of file diff --git a/Project.View/NewLogin/NewLogin.axaml.cs b/Project.View/NewLogin/NewLogin.axaml.cs index c5abe36..d047fa2 100644 --- a/Project.View/NewLogin/NewLogin.axaml.cs +++ b/Project.View/NewLogin/NewLogin.axaml.cs @@ -23,12 +23,23 @@ public partial class NewLogin : Window private void NewLoginSaveOnClick(object? sender, RoutedEventArgs e) { - string username = NewLoginUsernameBox.Text?.Trim(); - string password = NewLoginPasswordBox.Text?.Trim(); - string email = NewLoginEmailBox.Text?.Trim(); + string username = NewLoginUsernameBox.Text?.Trim() ?? string.Empty; + string password = NewLoginPasswordBox.Text?.Trim() ?? string.Empty; + string email = NewLoginEmailBox.Text?.Trim() ?? string.Empty; + //test inputs: + bool masterLoginPasswordBool = InputSanitizer.MasterLoginPasswordBool(password); + bool masterLoginEmailBool = InputSanitizer.MasterLoginEmailBool(email); + bool masterLoginNameBool = InputSanitizer.MasterLoginNameBool(username); //give strings to appcontroller and keep working on them there - AppController.NewLoginSave(username, password, email); - Close(); + if (masterLoginPasswordBool || masterLoginEmailBool || masterLoginNameBool) + { + AppController.NewLoginSave(username, password, email); + Close(); + } + else + { + + } } private void NewLoginCancelOnClick(object? sender, RoutedEventArgs e)