started adding input san for masterlogin creation
This commit is contained in:
parent
0e8203eadd
commit
0340ad662d
@ -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)
|
||||
{
|
||||
|
||||
23
Project.Controller/InputSanitizer.cs
Normal file
23
Project.Controller/InputSanitizer.cs
Normal file
@ -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;
|
||||
}
|
||||
}
|
||||
@ -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)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user