Fix launcher breaking on login/register

This commit is contained in:
CWX
2025-01-10 23:01:22 +00:00
parent 7bb98b6991
commit 97c5fb257e
2 changed files with 33 additions and 10 deletions
+31 -8
View File
@@ -1,28 +1,51 @@
using Core.DI;
using Core.Annotations;
using Core.DI;
using Core.Models.Enums;
using Core.Models.Spt.Config;
using Core.Servers;
using Core.Services;
namespace Core.Callbacks;
[Injectable]
public class SaveCallbacks : OnLoad, OnUpdate
{
private CoreConfig _coreConfig;
protected SaveServer _saveServer;
protected CoreConfig _coreConfig;
protected BackupService _backupService;
public SaveCallbacks()
public SaveCallbacks(
SaveServer saveServer,
ConfigServer configServer,
BackupService backupService
)
{
_saveServer = saveServer;
_coreConfig = configServer.GetConfig<CoreConfig>(ConfigTypes.CORE);
_backupService = backupService;
}
public async Task OnLoad()
public Task OnLoad()
{
throw new NotImplementedException();
_backupService.InitAsync();
_saveServer.Load();
return Task.CompletedTask;
}
public async Task<bool> OnUpdate(long SecondsSinceLastRun)
{
throw new NotImplementedException();
if (SecondsSinceLastRun > _coreConfig.ProfileSaveIntervalInSeconds)
{
_saveServer.Save();
return true;
}
return false;
}
public string GetRoute()
{
throw new NotImplementedException();
return "spt-save";
}
}
}
+2 -2
View File
@@ -102,7 +102,7 @@ public class LauncherController
return _saveServer.GetProfiles().TryGetValue(sessionId, out var profile) ? profile.ProfileInfo : null;
}
public string Login(LoginRequestData info)
public string? Login(LoginRequestData info)
{
foreach (var sessionID in _saveServer.GetProfiles()) {
var account = _saveServer.GetProfile(sessionID.Key).ProfileInfo;
@@ -111,7 +111,7 @@ public class LauncherController
}
}
return "";
return null;
}
public string Register(RegisterData info)