finish migration to Pilz.NET

This commit is contained in:
Schedel Pascal
2024-08-23 11:18:46 +02:00
parent 90283ff5df
commit 4cd52de441
10 changed files with 103 additions and 110 deletions

View File

@@ -12,7 +12,7 @@ using Pilz.Plugins.Advanced;
namespace OwnChar.Server;
internal class ServerContext(ISettings settings) : ApiServer(settings.Get<ServerSettings>().ApiUrl!), IServer
internal class ServerContext(ISettings settings) : ApiServer(settings.Get<ServerSettings>().ApiUrl!), IOwnCharServer
{
private readonly Dictionary<string, UserAccountBase> users = [];
@@ -47,12 +47,19 @@ internal class ServerContext(ISettings settings) : ApiServer(settings.Get<Server
protected override string? DecodeAuthKey(string authKey)
{
return base.DecodeAuthKey(new SecureString(authKey, true));
if (!string.IsNullOrWhiteSpace(authKey))
return new SecureString(authKey, true).Value;
return authKey;
}
protected override bool CheckAuthentication(string authKey)
{
return base.CheckAuthentication(authKey) || IsLoggedIn(authKey);
return string.IsNullOrWhiteSpace(authKey)
|| authKey.Split(":") is not string[] authKeyParts
|| authKey.Length != 2
|| string.IsNullOrWhiteSpace(authKeyParts[0])
|| string.IsNullOrWhiteSpace(authKeyParts[1])
|| !IsLoggedIn(authKeyParts[1]);
}
public string Login(UserAccountBase account)