started working on the login itself, need to add the sql query
This commit is contained in:
parent
86e9c8f6f3
commit
a2bef7626a
@ -4,10 +4,18 @@ namespace Project.Controller;
|
|||||||
|
|
||||||
public partial class AppController
|
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)
|
public static void NewLoginSave(string username, string password, string email)
|
||||||
{
|
{
|
||||||
string hashedPassword = ShaHash.HashPassword(password);
|
string hashedPassword = ShaHash.HashPassword(password);
|
||||||
var user = new NewUser(username, hashedPassword, email);
|
var user = new NewUser(username, hashedPassword, email);
|
||||||
SQLite.SaveUser(user);
|
SQLite.SaveUser(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void CompareLogin(string username, string password)
|
||||||
|
{
|
||||||
|
string hashedPassword = ShaHash.HashPassword(password);
|
||||||
|
string Username = username;
|
||||||
|
SQLite.GetLogin(Username, hashedPassword);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -45,7 +45,6 @@ public partial class SQLite
|
|||||||
{
|
{
|
||||||
using var connection = new SqliteConnection($"Data Source={_dbPath}");
|
using var connection = new SqliteConnection($"Data Source={_dbPath}");
|
||||||
connection.Open();
|
connection.Open();
|
||||||
connection.Open();
|
|
||||||
using (var command = connection.CreateCommand())
|
using (var command = connection.CreateCommand())
|
||||||
{
|
{
|
||||||
command.Parameters.AddWithValue("@loginname", user.NewLoginName);
|
command.Parameters.AddWithValue("@loginname", user.NewLoginName);
|
||||||
|
|||||||
19
Project.Persistence/SQLite2.cs
Normal file
19
Project.Persistence/SQLite2.cs
Normal file
@ -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 =
|
||||||
|
@"
|
||||||
|
";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -14,7 +14,10 @@
|
|||||||
Orientation="Vertical"
|
Orientation="Vertical"
|
||||||
VerticalAlignment="Center">
|
VerticalAlignment="Center">
|
||||||
<TextBlock>Your Login Name:</TextBlock>
|
<TextBlock>Your Login Name:</TextBlock>
|
||||||
<TextBox TextWrapping="Wrap" Watermark="Login-Name" />
|
<TextBox
|
||||||
|
TextWrapping="Wrap"
|
||||||
|
Watermark="Login-Name"
|
||||||
|
x:Name="LoginNameBox" />
|
||||||
|
|
||||||
<TextBlock>Password:</TextBlock>
|
<TextBlock>Password:</TextBlock>
|
||||||
|
|
||||||
@ -22,7 +25,8 @@
|
|||||||
<TextBox
|
<TextBox
|
||||||
PasswordChar="*"
|
PasswordChar="*"
|
||||||
TextWrapping="Wrap"
|
TextWrapping="Wrap"
|
||||||
Watermark="Password" />
|
Watermark="Password"
|
||||||
|
x:Name="LoginPasswordBox" />
|
||||||
<Button
|
<Button
|
||||||
BorderBrush="Black"
|
BorderBrush="Black"
|
||||||
BorderThickness="1"
|
BorderThickness="1"
|
||||||
|
|||||||
@ -17,9 +17,12 @@ public partial class LoginPage : UserControl
|
|||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_controller = controller;
|
_controller = controller;
|
||||||
}
|
}
|
||||||
|
//gives loginname and password over to the appcontroller to compare the logins
|
||||||
private async void LoginButtonOnClick(object? sender, Avalonia.Interactivity.RoutedEventArgs e)
|
private async void LoginButtonOnClick(object? sender, Avalonia.Interactivity.RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
|
string? loginName = LoginNameBox.Text ?? string.Empty;
|
||||||
|
string? loginPassword = LoginPasswordBox.Text ?? string.Empty;
|
||||||
|
AppController.CompareLogin(loginName, loginPassword);
|
||||||
}
|
}
|
||||||
private async void NewUserButtonOnClick(object? sender, Avalonia.Interactivity.RoutedEventArgs e)
|
private async void NewUserButtonOnClick(object? sender, Avalonia.Interactivity.RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user