This commit is contained in:
2022-06-20 22:27:33 +00:00
parent 0e7d1de1ed
commit 7ced9e377c
2 changed files with 31 additions and 25 deletions

View File

@@ -12,7 +12,7 @@ namespace AyaNovaQBI
{
public partial class tfa : Form
{
public string TFACode { get; set; }
public string TFAPin { get; set; }
public tfa()
{
InitializeComponent();
@@ -24,18 +24,15 @@ namespace AyaNovaQBI
}
private async void btnVerifyCode_click(object sender, EventArgs e)
private void btnVerifyCode_click(object sender, EventArgs e)
{
var res = await util.AuthenticateTFAAsync(ed);
if (!res)
TFAPin = edTFACode.Text;
if (string.IsNullOrWhiteSpace(TFAPin))
{
MessageBox.Show("Login failed");
btnLogin.Enabled = btnTest.Enabled = true;
this.DialogResult = DialogResult.Cancel;
MessageBox.Show("TFA Code is required to log in");
return;
}
this.DialogResult = DialogResult.OK;
this.Close();
}

View File

@@ -100,30 +100,39 @@ namespace AyaNovaQBI
if (response.IsSuccessStatusCode)
{
var a = new ApiResponse() { HttpResponse = response, ObjectResponse = Parse(await response.Content.ReadAsStringAsync()) };
bool tfa = a.ObjectResponse["data"]["tfa"].Value<bool>();
if (tfa == true)
{
//Get temp token from response
var tempToken = a.ObjectResponse["data"]["tt"].Value<string>();
string tfaPin = null;
bool keepTrying = true;
//get 2fa code and send it in
do
{
tfa t = new tfa();
if (t.ShowDialog() == System.Windows.Forms.DialogResult.Cancel) return false;
tfaPin = t.TFAPin;
} while (keepTrying);
}
else
{
JWT = a.ObjectResponse["data"]["token"].Value<string>();
return true;
}
}
return false;
}
public async static Task<ApiResponse> GetAsync(string route)
{
Exception FirstException = null;