implemented input sanitization for login creation but only with an exception for now
This commit is contained in:
parent
0340ad662d
commit
86e9c8f6f3
@ -1,20 +1,21 @@
|
||||
namespace Project.Controller;
|
||||
|
||||
public class InputSanitizer
|
||||
public partial class InputSanitizer
|
||||
{
|
||||
//MasterLogin - Password Check
|
||||
public static bool MasterLoginPasswordBool(string password)
|
||||
{
|
||||
if (string.IsNullOrEmpty(password) || password.Length < 6) return false;
|
||||
else return true;
|
||||
}
|
||||
|
||||
//MasterLogin - Email Check
|
||||
public static bool MasterLoginEmailBool(string email)
|
||||
{
|
||||
if (string.IsNullOrEmpty(email)) return false;
|
||||
if (email.Contains('@') && email.Length > 6) return true;
|
||||
else return false;
|
||||
}
|
||||
|
||||
//MasterLogin - Name Check
|
||||
public static bool MasterLoginNameBool(string username)
|
||||
{
|
||||
if (string.IsNullOrEmpty(username) || username.Length < 4) return false;
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
public class Entry
|
||||
{
|
||||
public string? Entryname;
|
||||
public string? Name;
|
||||
public string? Username;
|
||||
public string? Password;
|
||||
public string? Url;
|
||||
|
||||
@ -2,7 +2,7 @@ using Microsoft.Data.Sqlite;
|
||||
using Project.Model;
|
||||
namespace Project.Persistence;
|
||||
|
||||
public class SQLite
|
||||
public partial class SQLite
|
||||
{
|
||||
//filepath for home-pc:
|
||||
//private static string _dbPath = "C:/Users/Soi/Project_Keywi/keywi.db";
|
||||
@ -40,7 +40,7 @@ public class SQLite
|
||||
command.ExecuteNonQuery();
|
||||
}
|
||||
|
||||
//saves a new user to the table LOGINS ----- no input sanitization yet
|
||||
//saves a new user to the table LOGINS
|
||||
public static void SaveUser(NewUser user)
|
||||
{
|
||||
using var connection = new SqliteConnection($"Data Source={_dbPath}");
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.Media;
|
||||
@ -31,14 +32,14 @@ public partial class NewLogin : Window
|
||||
bool masterLoginEmailBool = InputSanitizer.MasterLoginEmailBool(email);
|
||||
bool masterLoginNameBool = InputSanitizer.MasterLoginNameBool(username);
|
||||
//give strings to appcontroller and keep working on them there
|
||||
if (masterLoginPasswordBool || masterLoginEmailBool || masterLoginNameBool)
|
||||
if (masterLoginPasswordBool && masterLoginEmailBool && masterLoginNameBool)
|
||||
{
|
||||
AppController.NewLoginSave(username, password, email);
|
||||
Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
throw new Exception("Master Login Creation Failed");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user