From 50aadeeecf94619f755f002faf82d32eb3958ff4 Mon Sep 17 00:00:00 2001 From: Derek Holloway Date: Thu, 31 Jul 2025 18:31:13 -0700 Subject: [PATCH 1/2] Retry public key until it works --- src/Server/Program.cs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/Server/Program.cs b/src/Server/Program.cs index 1ec73c9..e4748e6 100755 --- a/src/Server/Program.cs +++ b/src/Server/Program.cs @@ -89,20 +89,20 @@ if (IPayment._PaymentType == PaymentType.StripeIntent) { RsaSecurityKey? PublicKey = null; using (HttpClient client = new HttpClient()) { - HttpResponseMessage PublicKeyResponse = await client.GetAsync("https://auth.mistox.com/api/auth/publickey"); - if (PublicKeyResponse.IsSuccessStatusCode) { - string publicKey = await PublicKeyResponse.Content.ReadAsStringAsync(); - RSA rsa = RSA.Create(); - rsa.ImportFromPem(publicKey); - PublicKey = new RsaSecurityKey(rsa); + while (PublicKey == null) { + HttpResponseMessage PublicKeyResponse = await client.GetAsync("https://auth.mistox.com/api/auth/publickey"); + if (PublicKeyResponse.IsSuccessStatusCode) { + string publicKey = await PublicKeyResponse.Content.ReadAsStringAsync(); + using (RSA rsa = RSA.Create()) { + rsa.ImportFromPem(publicKey); + PublicKey = new RsaSecurityKey(rsa); + } + } else { + await Task.Delay(2000); // sleep the main thread for 2 seconds before sending another request. Prevent DDOS of my own equiptment + } } } -if (PublicKey == null) { - Console.WriteLine("Unable to load RSA PubKey Shutting Down"); - Environment.Exit(100); -} - builder.Services.AddAuthentication(options => { options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme; From 31708cdb150c6cec3dff03f0143342de0614f490 Mon Sep 17 00:00:00 2001 From: Derek Holloway Date: Thu, 31 Jul 2025 18:36:44 -0700 Subject: [PATCH 2/2] Fix login errors --- src/Client/src/app/services/Authentication.ts | 2 +- src/Server/Controllers/AuthenticationController.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Client/src/app/services/Authentication.ts b/src/Client/src/app/services/Authentication.ts index f653b1b..93bf139 100644 --- a/src/Client/src/app/services/Authentication.ts +++ b/src/Client/src/app/services/Authentication.ts @@ -31,7 +31,7 @@ export class Authentication{ } get isLoggedIn(): boolean { - return this._user.value.id != -1 ? true : false; + return this._user.value.id == null ? true : false; } get loggedInUser(): Account { diff --git a/src/Server/Controllers/AuthenticationController.cs b/src/Server/Controllers/AuthenticationController.cs index 2a55b40..96180d4 100755 --- a/src/Server/Controllers/AuthenticationController.cs +++ b/src/Server/Controllers/AuthenticationController.cs @@ -43,7 +43,7 @@ namespace BoredCareers.Controllers { signOut(); return Redirect("/"); } - return NotFound(); + return NotFound("Not logged in"); } }