Files
Nebula-Auth/src/NebulaAuth/Model/SessionHandler/SessionHandler_API.cs
T
achiez f15632f2d0 Refactored MAAC error/status handling and UI feedback
- Introduced centralized MAACRequestHandler for error tracking, retries, and status escalation (Ok/Warning/Error) per account
- PortableMaClient now uses new Status property (PortableMaClientStatus) instead of IsError; error history tracked in PortableMaClientErrorData
- All MAAC requests now routed through MAACRequestHandler, providing unified error handling and retry logic
- MultiAccountAutoConfirmer now filters accounts by Status.StatusType == Ok
- Updated MainWindow UI: account name color reflects status (Success/Warning/Error); added "Unattach proxy" to context menu
- Removed obsolete PortableMaClientStatusToColorConverter and related bindings
- Settings: removed IgnorePatchTuesdayErrors, added MaacErrorThreshold and MaacRetryInterval for error escalation control
- Refactored SessionHandler: split into logic, API, and helpers; improved exception propagation and session management
- AdmissionHelper methods now handle null sessions and always transfer community cookies if session is missing
- Mafile export: always preserves SteamId, even if session data is not exported
- ViewModel: RemoveProxy command now parameterized and only enabled if Mafile has a proxy
- Enabled concurrent log writing in NLog config
- Minor code cleanups and improved exception signatures
2026-01-25 18:48:11 +02:00

57 lines
2.5 KiB
C#

using System.Threading.Tasks;
using AchiesUtilities.Web.Models;
using NebulaAuth.Model.Entities;
using NebulaAuth.Model.Mafiles;
using SteamLib.Api.Mobile;
using SteamLib.Authentication;
using SteamLib.Authentication.LoginV2;
using SteamLib.Exceptions.Authorization;
using SteamLib.Factory.Helpers;
using SteamLib.SteamMobile;
using SteamLibForked.Models.Session;
namespace NebulaAuth.Model;
public partial class SessionHandler //API
{
public static async Task RefreshMobileToken(HttpClientHandlerPair chp, Mafile mafile)
{
if (mafile.SessionData is not {RefreshToken.IsExpired: false})
throw new SessionPermanentlyExpiredException(SessionInvalidException.SESSION_NULL_MSG);
var mobileToken = await SteamMobileApi.RefreshJwt(chp.Client, mafile.SessionData.RefreshToken.Token,
mafile.SessionData.SteamId);
Shell.Logger.Info("MobileToken on {name} {steamid} successfully refreshed", mafile.AccountName,
mafile.SessionData.SteamId);
var newToken = SteamTokenHelper.Parse(mobileToken);
mafile.SessionData.SetMobileToken(newToken);
//Trigger PropertyChanged event for PortableMaClient handling session updated from MaClient
mafile.SetSessionData(mafile.SessionData);
await Storage.UpdateMafileAsync(mafile);
chp.Handler.CookieContainer.SetSteamMobileCookiesWithMobileToken(mafile.SessionData);
}
public static async Task LoginAgain(HttpClientHandlerPair chp, Mafile mafile, string password, bool savePassword)
{
var sgGenerator = new SteamGuardCodeGenerator(mafile.SharedSecret);
var options = new LoginV2ExecutorOptions(StaticLoginConsumer.Instance, chp.Client)
{
Logger = Shell.ExtensionsLogger,
AuthProviders = [sgGenerator],
DeviceDetails = DeviceDetailsDefaultBuilder.GetMobileDefaultDevice(),
WebsiteId = "Mobile"
};
chp.Handler.CookieContainer.ClearMobileSessionCookies();
var result = await LoginV2Executor.DoLogin(options, mafile.AccountName, password);
Shell.Logger.Info("Logged in again on {name} {steamid}", mafile.AccountName, result.SteamId);
AdmissionHelper.TransferCommunityCookies(chp.Handler.CookieContainer);
//Triggers PropertyChanged event for PortableMaClient handling session updated from MaClient
mafile.SetSessionData((MobileSessionData) result);
if (PHandler.IsPasswordSet)
mafile.Password = savePassword ? PHandler.Encrypt(password) : null;
await Storage.UpdateMafileAsync(mafile);
}
}