From a2bef7626ac5a3afbe5545261deeb7f754c22382 Mon Sep 17 00:00:00 2001 From: Taarly Date: Tue, 6 May 2025 09:25:57 +0200 Subject: [PATCH] started working on the login itself, need to add the sql query --- Project.Controller/AppController.cs | 8 ++++++++ Project.Persistence/SQLite.cs | 1 - Project.Persistence/SQLite2.cs | 19 +++++++++++++++++++ Project.View/Login Page/LoginPage.axaml | 8 ++++++-- Project.View/Login Page/LoginPage.axaml.cs | 5 ++++- 5 files changed, 37 insertions(+), 4 deletions(-) create mode 100644 Project.Persistence/SQLite2.cs diff --git a/Project.Controller/AppController.cs b/Project.Controller/AppController.cs index 6b23eee..0b4a883 100644 --- a/Project.Controller/AppController.cs +++ b/Project.Controller/AppController.cs @@ -4,10 +4,18 @@ namespace Project.Controller; public partial class AppController { + //save new login - hashes the password and gives it to persistence public static void NewLoginSave(string username, string password, string email) { string hashedPassword = ShaHash.HashPassword(password); var user = new NewUser(username, hashedPassword, email); SQLite.SaveUser(user); } + + public static void CompareLogin(string username, string password) + { + string hashedPassword = ShaHash.HashPassword(password); + string Username = username; + SQLite.GetLogin(Username, hashedPassword); + } } diff --git a/Project.Persistence/SQLite.cs b/Project.Persistence/SQLite.cs index e10f9b1..3ce9046 100644 --- a/Project.Persistence/SQLite.cs +++ b/Project.Persistence/SQLite.cs @@ -45,7 +45,6 @@ public partial class SQLite { using var connection = new SqliteConnection($"Data Source={_dbPath}"); connection.Open(); - connection.Open(); using (var command = connection.CreateCommand()) { command.Parameters.AddWithValue("@loginname", user.NewLoginName); diff --git a/Project.Persistence/SQLite2.cs b/Project.Persistence/SQLite2.cs new file mode 100644 index 0000000..8789802 --- /dev/null +++ b/Project.Persistence/SQLite2.cs @@ -0,0 +1,19 @@ +using Microsoft.Data.Sqlite; +using Project.Model; +namespace Project.Persistence; + +public partial class SQLite +{ + //get login name and password to compare it with inputs + public static void GetLogin(string username, string password) + { + using var connection = new SqliteConnection($"Data Source={_dbPath}"); + connection.Open(); + using (var command = connection.CreateCommand()) + { + command.CommandText = + @" + "; + } + } +} \ No newline at end of file diff --git a/Project.View/Login Page/LoginPage.axaml b/Project.View/Login Page/LoginPage.axaml index 7f33e9d..b2c369b 100644 --- a/Project.View/Login Page/LoginPage.axaml +++ b/Project.View/Login Page/LoginPage.axaml @@ -14,7 +14,10 @@ Orientation="Vertical" VerticalAlignment="Center"> Your Login Name: - + Password: @@ -22,7 +25,8 @@ + Watermark="Password" + x:Name="LoginPasswordBox" />