From d6d0f1262655ade64ec0b5895a1d2ba7f931f150 Mon Sep 17 00:00:00 2001 From: Elijah R Date: Mon, 8 Apr 2024 21:25:40 -0400 Subject: [PATCH] implement account support --- CollabVMSharp | 2 +- EmperorPalpatine/IConfig.cs | 3 ++- EmperorPalpatine/VM.cs | 16 +++++++++++++++- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/CollabVMSharp b/CollabVMSharp index 0440abd..7117823 160000 --- a/CollabVMSharp +++ b/CollabVMSharp @@ -1 +1 @@ -Subproject commit 0440abd027aeb35299ea05f275841a9ef012a6f4 +Subproject commit 7117823772a3615890dfc833bce81cc05be15426 diff --git a/EmperorPalpatine/IConfig.cs b/EmperorPalpatine/IConfig.cs index 58748f1..a89f1ab 100644 --- a/EmperorPalpatine/IConfig.cs +++ b/EmperorPalpatine/IConfig.cs @@ -31,7 +31,8 @@ public class ConfigVM public string Name { get; set; } public string URL { get; set; } public string Node { get; set; } - public string Password { get; set; } + public string? Password { get; set; } + public string? Token { get; set; } public ulong[]? DiscordMods { get; set; } } diff --git a/EmperorPalpatine/VM.cs b/EmperorPalpatine/VM.cs index 93dd698..858f5fa 100644 --- a/EmperorPalpatine/VM.cs +++ b/EmperorPalpatine/VM.cs @@ -21,6 +21,16 @@ public class VM public VM(string username, ConfigVM config, Database db) { this.Config = config; + if (this.Config.Password == null && this.Config.Token == null) + { + Utilities.Log(LogLevel.FATAL, $"VM {this.Config.Name} has no password or token set."); + Environment.Exit(1); + } + if (this.Config.Password != null && this.Config.Token != null) + { + Utilities.Log(LogLevel.FATAL, $"VM {this.Config.Name} has both a password and token set."); + Environment.Exit(1); + } this.username = username; this.database = db; retryTimer.Interval = 1000; @@ -91,7 +101,11 @@ public class VM retryTimer.Start(); return; } - await cvm.Login(Config.Password); + + if (this.Config.Password != null) + await cvm.Login(Config.Password); + else + await cvm.LoginAccount(Config.Token!); GotAuth.TrySetResult(null); }