33 lines
1.2 KiB
C#
33 lines
1.2 KiB
C#
using Project.Persistence;
|
|
using Project.Model;
|
|
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);
|
|
}
|
|
|
|
//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);
|
|
string Username = username;
|
|
var savedPassword = SQLite.GetLogin(Username);
|
|
return hashedPassword == savedPassword;
|
|
}
|
|
}
|