use client/server model

This commit is contained in:
2024-07-21 09:53:17 +02:00
parent 005685ee2a
commit e88d1ff009
4 changed files with 9 additions and 8 deletions

View File

@@ -15,7 +15,7 @@ namespace OwnChar.ServerNew;
internal class ServerContext(ISettings settings) : Api.IServer
{
private readonly Dictionary<string, UserAccount> users = [];
private readonly Dictionary<string, UserAccountBase> users = [];
public DbContext? Data { get; private set; }
@@ -72,7 +72,7 @@ internal class ServerContext(ISettings settings) : Api.IServer
app.Run();
}
public string Login(UserAccount account)
public string Login(UserAccountBase account)
{
var secret = new UniquieID(UniquieIDGenerationMode.GenerateOnInit).ID;
users.Add(secret, account);
@@ -99,10 +99,10 @@ internal class ServerContext(ISettings settings) : Api.IServer
throw new UnauthorizedAccessException();
}
public UserAccount? GetUser(string secret)
public UserAccountBase? GetUser(string secret)
{
Log.DebugFormat("Getting user with secret {0}", secret);
if (users.TryGetValue(secret, out UserAccount? value))
if (users.TryGetValue(secret, out UserAccountBase? value))
return value;
return null;
}