59 lines
1.8 KiB
C#
59 lines
1.8 KiB
C#
using System;
|
|
using Avalonia.Controls;
|
|
using Avalonia.Interactivity;
|
|
using Avalonia.Media;
|
|
using Project.Controller;
|
|
using Project.Model;
|
|
using Project.Persistence;
|
|
|
|
namespace Project.View;
|
|
|
|
public partial class NewLogin : Window
|
|
{
|
|
readonly AppController? _controller;
|
|
public NewLogin()
|
|
{
|
|
InitializeComponent();
|
|
_controller = new();
|
|
Title = "KEYWI - your password manager!";
|
|
}
|
|
|
|
public NewLogin(AppController controller)
|
|
{
|
|
InitializeComponent();
|
|
_controller = controller;
|
|
}
|
|
|
|
//saves the new user to the database
|
|
private void NewLoginSaveOnClick(object? sender, RoutedEventArgs e)
|
|
{
|
|
string username = NewLoginUsernameBox.Text?.Trim() ?? string.Empty;
|
|
string password = NewLoginPasswordBox.Text?.Trim() ?? string.Empty;
|
|
string email = NewLoginEmailBox.Text?.Trim() ?? string.Empty;
|
|
//test inputs:
|
|
bool masterLoginPasswordBool = InputSanitizer.MasterLoginPasswordBool(password);
|
|
bool masterLoginEmailBool = InputSanitizer.MasterLoginEmailBool(email);
|
|
bool masterLoginNameBool = InputSanitizer.MasterLoginNameBool(username);
|
|
|
|
//give strings to appcontroller and keep working on them there
|
|
if (masterLoginPasswordBool && masterLoginEmailBool && masterLoginNameBool)
|
|
{
|
|
AppController.NewLoginSave(username, password, email);
|
|
Close();
|
|
}
|
|
else
|
|
{
|
|
NewLoginUsernameBox.Text = string.Empty;
|
|
NewLoginPasswordBox.Text = string.Empty;
|
|
NewLoginEmailBox.Text = string.Empty;
|
|
var ShowPopup = new PopUp();
|
|
ShowPopup.ShowDialog(this);
|
|
}
|
|
}
|
|
|
|
//closes the window on click
|
|
private void NewLoginCancelOnClick(object? sender, RoutedEventArgs e)
|
|
{
|
|
Close();
|
|
}
|
|
} |