Skip to content

Commit 10ea19e

Browse files
committed
Fix TOTP, accidentally attempted to apply OTP at the wrong stage.
1 parent 38a5052 commit 10ea19e

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

Classes/pveAPI/ApiClient.cs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,17 +86,13 @@ public bool LoginRequest(string username, string password, string realm, string
8686
loginData.Add("password", password);
8787
loginData.Add("realm", realm);
8888

89-
if (otp != null)
90-
{
91-
loginData.Add("otp", otp);
92-
}
93-
9489
// Serialize the object to JSON
9590
var jsonContent = JsonConvert.SerializeObject(loginData);
9691
var httpContent = new StringContent(jsonContent, Encoding.UTF8, "application/json");
9792

9893
// Attempt Ticket Request
9994
var response = _httpClient.PostAsync("access/ticket", httpContent).GetAwaiter().GetResult();
95+
Program.DebugPoint("Program Error (Login Request): " + Environment.NewLine + JsonConvert.SerializeObject(response));
10096

10197
// Process If Successful
10298
if (response.IsSuccessStatusCode)
@@ -155,10 +151,13 @@ private bool TotpChallengeRequest(string otpCode)
155151
var httpContent = new StringContent(jsonContent, Encoding.UTF8, "application/json");
156152
var response = _httpClient.PostAsync("access/ticket", httpContent).GetAwaiter().GetResult();
157153

158-
Console.WriteLine(JsonConvert.SerializeObject(response.Content));
154+
Program.DebugPoint("Program Error (TOTPChallengeRequest): " + Environment.NewLine + JsonConvert.SerializeObject(response));
155+
159156
if (response.IsSuccessStatusCode)
160157
{
161-
dynamic apiResponse = JsonConvert.DeserializeObject(response.Content.ReadAsStringAsync().GetAwaiter().GetResult());
158+
string responseData = response.Content.ReadAsStringAsync().GetAwaiter().GetResult();
159+
dynamic apiResponse = JsonConvert.DeserializeObject(responseData);
160+
162161
DataTicket = new DataTicket
163162
{
164163
ticket = apiResponse!.data.ticket,

Program.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.Diagnostics;
34
using System.Linq;
45
using System.Threading.Tasks;
56
using System.Windows.Forms;
@@ -37,9 +38,10 @@ static void Main()
3738

3839
public static void DebugPoint(string content)
3940
{
40-
#if DEBUG
41+
if (Debugger.IsAttached)
42+
{
4143
Console.WriteLine(content);
42-
#endif
44+
}
4345
}
4446

4547
}

0 commit comments

Comments
 (0)