saving a new entry is possible now, but the owner isnt automatically set yet
This commit is contained in:
parent
af780414ac
commit
cceb2cc7ee
@ -12,6 +12,16 @@ public partial class AppController
|
|||||||
SQLite.SaveUser(user);
|
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)
|
public static bool CompareLogin(string username, string password)
|
||||||
{
|
{
|
||||||
string hashedPassword = ShaHash.HashPassword(password);
|
string hashedPassword = ShaHash.HashPassword(password);
|
||||||
|
|||||||
@ -5,9 +5,9 @@ namespace Project.Persistence;
|
|||||||
public partial class SQLite
|
public partial class SQLite
|
||||||
{
|
{
|
||||||
//filepath for home-pc:
|
//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:
|
//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
|
//KLASSENVARIABLEN ERSTELLEN
|
||||||
//private static string loginname;
|
//private static string loginname;
|
||||||
|
|
||||||
|
|||||||
@ -4,7 +4,8 @@ namespace Project.Persistence;
|
|||||||
|
|
||||||
public partial class SQLite
|
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}");
|
using var connection = new SqliteConnection($"Data Source={_dbPath}");
|
||||||
connection.Open();
|
connection.Open();
|
||||||
|
|||||||
@ -13,18 +13,18 @@
|
|||||||
FontSize="20"
|
FontSize="20"
|
||||||
HorizontalAlignment="Left"
|
HorizontalAlignment="Left"
|
||||||
Text="Name:" />
|
Text="Name:" />
|
||||||
<TextBox TextWrapping="Wrap" Watermark="Name:" />
|
<TextBox TextWrapping="Wrap" Watermark="Name:" x:Name="NameBox"/>
|
||||||
<TextBlock
|
<TextBlock
|
||||||
FontSize="20"
|
FontSize="20"
|
||||||
HorizontalAlignment="Left"
|
HorizontalAlignment="Left"
|
||||||
Text="Username:" />
|
Text="Username/Email:" />
|
||||||
<TextBox TextWrapping="Wrap" Watermark="Username" />
|
<TextBox TextWrapping="Wrap" Watermark="Username/Email" x:Name="UsernameMailBox"/>
|
||||||
<TextBlock
|
<TextBlock
|
||||||
FontSize="20"
|
FontSize="20"
|
||||||
HorizontalAlignment="Left"
|
HorizontalAlignment="Left"
|
||||||
Margin="23"
|
Margin="23"
|
||||||
Text="Email:" />
|
Text="Email:" />
|
||||||
<TextBox TextWrapping="Wrap" Watermark="E-Mail" />
|
<TextBox TextWrapping="Wrap" Watermark="E-Mail" x:Name="EmailBox"/>
|
||||||
<TextBlock
|
<TextBlock
|
||||||
FontSize="20"
|
FontSize="20"
|
||||||
HorizontalAlignment="Left"
|
HorizontalAlignment="Left"
|
||||||
@ -35,7 +35,7 @@
|
|||||||
<TextBox
|
<TextBox
|
||||||
Name="NewentryPW"
|
Name="NewentryPW"
|
||||||
PasswordChar="*"
|
PasswordChar="*"
|
||||||
Watermark="Password" />
|
Watermark="Password" x:Name="PassBox"/>
|
||||||
<Button
|
<Button
|
||||||
BorderBrush="Black"
|
BorderBrush="Black"
|
||||||
BorderThickness="1"
|
BorderThickness="1"
|
||||||
@ -52,7 +52,7 @@
|
|||||||
FontSize="20"
|
FontSize="20"
|
||||||
HorizontalAlignment="Left"
|
HorizontalAlignment="Left"
|
||||||
Text="Note:" />
|
Text="Note:" />
|
||||||
<TextBox TextWrapping="Wrap" Watermark="Note" />
|
<TextBox TextWrapping="Wrap" Watermark="Note" x:Name="NoteBox"/>
|
||||||
<StackPanel Orientation="Horizontal">
|
<StackPanel Orientation="Horizontal">
|
||||||
<Button
|
<Button
|
||||||
BorderBrush="Black"
|
BorderBrush="Black"
|
||||||
|
|||||||
@ -25,7 +25,13 @@ public partial class NewEntry : Window
|
|||||||
|
|
||||||
private void NewEntry_Save_Click(object? sender, RoutedEventArgs e)
|
private void NewEntry_Save_Click(object? sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
|
string name = NameBox.Text;
|
||||||
|
string username = UsernameMailBox.Text;
|
||||||
|
string email = EmailBox.Text;
|
||||||
|
string pass = PassBox.Text;
|
||||||
|
string note = NoteBox.Text;
|
||||||
|
AppController.NewEntrySave(name, username, email, pass, note);
|
||||||
|
Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void NewEntry_ShowPW_Click(object? sender, RoutedEventArgs e)
|
private void NewEntry_ShowPW_Click(object? sender, RoutedEventArgs e)
|
||||||
@ -39,4 +45,5 @@ public partial class NewEntry : Window
|
|||||||
NewentryPW.PasswordChar = '*';
|
NewentryPW.PasswordChar = '*';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user