From cceb2cc7eeaff2cc97c684493c456f2bc22808a5 Mon Sep 17 00:00:00 2001 From: taarly Date: Sun, 29 Jun 2025 11:01:22 +0200 Subject: [PATCH] saving a new entry is possible now, but the owner isnt automatically set yet --- Project.Controller/AppController.cs | 10 ++++++++++ Project.Persistence/SQLite.cs | 4 ++-- Project.Persistence/SQLite3.cs | 3 ++- Project.View/NewEntry/NewEntry.axaml | 12 ++++++------ Project.View/NewEntry/NewEntry.axaml.cs | 9 ++++++++- 5 files changed, 28 insertions(+), 10 deletions(-) diff --git a/Project.Controller/AppController.cs b/Project.Controller/AppController.cs index c0224de..7ece581 100644 --- a/Project.Controller/AppController.cs +++ b/Project.Controller/AppController.cs @@ -12,6 +12,16 @@ public partial class AppController SQLite.SaveUser(user); } + //save new entry - hashes the password and gives it to persistence + public static void NewEntrySave(string name, string usernameurl, string email, string password, string note) + { + string hashedPassword = ShaHash.HashPassword(password); + string ownerUsername = "user"; + SQLite.SaveEntry(name, hashedPassword, email, note, ownerUsername); + //string name, string pass, string mailUsername, string? note, string ownerUsername + } + + //compares the login and checks if the password is correct. public static bool CompareLogin(string username, string password) { string hashedPassword = ShaHash.HashPassword(password); diff --git a/Project.Persistence/SQLite.cs b/Project.Persistence/SQLite.cs index dfa1b03..646b25b 100644 --- a/Project.Persistence/SQLite.cs +++ b/Project.Persistence/SQLite.cs @@ -5,9 +5,9 @@ namespace Project.Persistence; public partial class SQLite { //filepath for home-pc: - //private static string _dbPath = "C:/Users/Soi/Project_Keywi/keywi.db"; + private static string _dbPath = "C:/Users/Soi/Desktop/keywi.db"; //filepath for work-laptop: - private static string _dbPath = "C:/Users/lowns/Desktop/keywi.db"; + //private static string _dbPath = "C:/Users/lowns/Desktop/keywi.db"; //KLASSENVARIABLEN ERSTELLEN //private static string loginname; diff --git a/Project.Persistence/SQLite3.cs b/Project.Persistence/SQLite3.cs index 0baf2d7..92d65de 100644 --- a/Project.Persistence/SQLite3.cs +++ b/Project.Persistence/SQLite3.cs @@ -4,7 +4,8 @@ namespace Project.Persistence; public partial class SQLite { - public static void SaveLogin(string name, string pass, string mailUsername, string? note, string ownerUsername) + //Method to save a new entry to SAVED_LOGINS + public static void SaveEntry(string name, string pass, string mailUsername, string? note, string ownerUsername) { using var connection = new SqliteConnection($"Data Source={_dbPath}"); connection.Open(); diff --git a/Project.View/NewEntry/NewEntry.axaml b/Project.View/NewEntry/NewEntry.axaml index 2fb3dc9..e28e050 100644 --- a/Project.View/NewEntry/NewEntry.axaml +++ b/Project.View/NewEntry/NewEntry.axaml @@ -13,18 +13,18 @@ FontSize="20" HorizontalAlignment="Left" Text="Name:" /> - + - + Text="Username/Email:" /> + - + + Watermark="Password" x:Name="PassBox"/>