Start der Backend Implementierung

Projekt für die Implementierung des Backends hinzugefügt. Klasse Logger --> Dient zum Loggen in die Datenbank. Klasse Ticket_System --> Hauptklasse für das die Backendanwendung. Auth Client hinzugefügt. Token stuff hinzugefügt.
This commit is contained in:
2026-01-28 12:48:40 +01:00
parent 1f38e7264b
commit 07b2a8ae0f
20 changed files with 354 additions and 0 deletions

View File

@@ -0,0 +1,51 @@
using MySqlConnector;
using BCrypt;
using System.ComponentModel.DataAnnotations;
namespace Ticket_System
{
public class Ticket_System
{
Logger logger = new Logger();
public string userID = "-";
private string? _token;
public async Task MainAsync(string[] args)
{
if (!await LoginAsync())
return;
await LoadTicketsAsync();
}
public async Task<bool> LoginAsync()
{
var auth = new AuthApiClient("http://localhost:3000");
string inputuser = "Carl";
string inputpw = "Deine Fette Mutter";
var tokenResp = await auth.SignInAsync(inputuser, inputpw);
if (tokenResp == null || string.IsNullOrWhiteSpace(tokenResp.token))
{
logger.Log("Login fehlgeschlagen (API)", userID);
return false;
}
_token = tokenResp.token;
bool ok = await auth.ValidateTokenAsync(_token);
logger.Log(ok ? "Token gültig" : "Token ungültig", userID);
return ok;
}
public async Task LoadTicketsAsync()
{
// hier würdest du bei weiteren API-Calls einfach den Token mitsenden:
// Authorization: Bearer <_token>
await Task.CompletedTask;
}
}
}