Added logging. Bug fix in MFA login form
This commit is contained in:
parent
ad09d36588
commit
b479096fc2
@ -67,9 +67,29 @@ namespace FileLiberator
|
|||||||
{
|
{
|
||||||
validate(libraryBook);
|
validate(libraryBook);
|
||||||
|
|
||||||
|
Serilog.Log.Logger.Debug("Trying to debug mysterious null ref exception {@DebugInfo}", new {
|
||||||
|
libraryBookIsNull = libraryBook is null,
|
||||||
|
BookIsNull = libraryBook?.Book is null,
|
||||||
|
libraryBook?.Book?.Locale,
|
||||||
|
libraryBook?.Book?.AudibleProductId,
|
||||||
|
AccountLength = libraryBook?.Account?.Length
|
||||||
|
});
|
||||||
|
|
||||||
var api = await InternalUtilities.AudibleApiActions.GetApiAsync(libraryBook.Account, libraryBook.Book.Locale);
|
var api = await InternalUtilities.AudibleApiActions.GetApiAsync(libraryBook.Account, libraryBook.Book.Locale);
|
||||||
|
|
||||||
|
Serilog.Log.Logger.Debug("Trying to debug mysterious null ref exception {@DebugInfo}", new { apiIsNull = api is null });
|
||||||
|
|
||||||
var contentLic = await api.GetDownloadLicenseAsync(libraryBook.Book.AudibleProductId);
|
var contentLic = await api.GetDownloadLicenseAsync(libraryBook.Book.AudibleProductId);
|
||||||
|
|
||||||
|
Serilog.Log.Logger.Debug("Trying to debug mysterious null ref exception {@DebugInfo}", new {
|
||||||
|
contentLicIsNull = contentLic is null,
|
||||||
|
contentMetadataIsNull = contentLic?.ContentMetadata is null,
|
||||||
|
voucherIsNull = contentLic?.Voucher is null,
|
||||||
|
keyIsNull = contentLic?.Voucher?.Key is null,
|
||||||
|
keyLength = contentLic?.Voucher?.Key?.Length,
|
||||||
|
ivIsNull = contentLic?.Voucher?.Iv is null,
|
||||||
|
ivLength = contentLic?.Voucher?.Iv?.Length,
|
||||||
|
});
|
||||||
|
|
||||||
var aaxcDecryptDlLic = new DownloadLicense
|
var aaxcDecryptDlLic = new DownloadLicense
|
||||||
(
|
(
|
||||||
|
|||||||
@ -13,7 +13,7 @@
|
|||||||
<!-- <PublishSingleFile>true</PublishSingleFile> -->
|
<!-- <PublishSingleFile>true</PublishSingleFile> -->
|
||||||
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
||||||
|
|
||||||
<Version>5.3.7.1</Version>
|
<Version>5.3.8.1</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@ -14,49 +14,74 @@ namespace LibationWinForms.Dialogs.Login
|
|||||||
{
|
{
|
||||||
private RadioButton[] radioButtons { get; }
|
private RadioButton[] radioButtons { get; }
|
||||||
|
|
||||||
|
AudibleApi.MfaConfig _mfaConfig { get; }
|
||||||
|
|
||||||
public MfaDialog(AudibleApi.MfaConfig mfaConfig)
|
public MfaDialog(AudibleApi.MfaConfig mfaConfig)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
|
_mfaConfig = mfaConfig;
|
||||||
|
|
||||||
radioButtons = new[] { this.radioButton1, this.radioButton2, this.radioButton3 };
|
radioButtons = new[] { this.radioButton1, this.radioButton2, this.radioButton3 };
|
||||||
|
|
||||||
// optional string settings
|
// optional string settings
|
||||||
if (!string.IsNullOrWhiteSpace(mfaConfig.Title))
|
if (!string.IsNullOrWhiteSpace(mfaConfig.Title))
|
||||||
this.Text = mfaConfig.Title;
|
this.Text = mfaConfig.Title;
|
||||||
setOptional(this.radioButton1, mfaConfig.Button1Text);
|
|
||||||
setOptional(this.radioButton2, mfaConfig.Button2Text);
|
|
||||||
setOptional(this.radioButton3, mfaConfig.Button3Text);
|
|
||||||
|
|
||||||
// mandatory values
|
setRadioButton(0, this.radioButton1);
|
||||||
radioButton1.Name = mfaConfig.Button1Name;
|
setRadioButton(1, this.radioButton2);
|
||||||
radioButton1.Tag = mfaConfig.Button1Value;
|
setRadioButton(2, this.radioButton3);
|
||||||
|
|
||||||
radioButton2.Name = mfaConfig.Button2Name;
|
Serilog.Log.Logger.Information("{@DebugInfo}", new {
|
||||||
radioButton2.Tag = mfaConfig.Button2Value;
|
paramButtonCount = mfaConfig.Buttons.Count,
|
||||||
|
visibleRadioButtonCount = radioButtons.Count(rb => rb.Visible)
|
||||||
radioButton3.Name = mfaConfig.Button3Name;
|
});
|
||||||
radioButton3.Tag = mfaConfig.Button3Value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void setOptional(RadioButton radioButton, string text)
|
private void setRadioButton(int pos, RadioButton rb)
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrWhiteSpace(text))
|
if (_mfaConfig.Buttons.Count <= pos)
|
||||||
radioButton.Text = text;
|
{
|
||||||
|
rb.Checked = false;
|
||||||
|
rb.Enabled = false;
|
||||||
|
rb.Visible = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var btn = _mfaConfig.Buttons[pos];
|
||||||
|
|
||||||
|
// optional
|
||||||
|
if (!string.IsNullOrWhiteSpace(btn.Text))
|
||||||
|
rb.Text = btn.Text;
|
||||||
|
|
||||||
|
// mandatory values
|
||||||
|
rb.Name = btn.Name;
|
||||||
|
rb.Tag = btn.Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string SelectedName { get; private set; }
|
public string SelectedName { get; private set; }
|
||||||
public string SelectedValue { get; private set; }
|
public string SelectedValue { get; private set; }
|
||||||
private void submitBtn_Click(object sender, EventArgs e)
|
private void submitBtn_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
Serilog.Log.Logger.Debug("RadioButton states: {@DebugInfo}", new {
|
Serilog.Log.Logger.Information("RadioButton states: {@DebugInfo}", new {
|
||||||
|
rb1_visible = radioButton1.Visible,
|
||||||
rb1_checked = radioButton1.Checked,
|
rb1_checked = radioButton1.Checked,
|
||||||
|
|
||||||
|
r21_visible = radioButton2.Visible,
|
||||||
r21_checked = radioButton2.Checked,
|
r21_checked = radioButton2.Checked,
|
||||||
|
|
||||||
|
rb3_visible = radioButton3.Visible,
|
||||||
rb3_checked = radioButton3.Checked
|
rb3_checked = radioButton3.Checked
|
||||||
});
|
});
|
||||||
|
|
||||||
var selected = radioButtons.Single(rb => rb.Checked);
|
var selected = radioButtons.FirstOrDefault(rb => rb.Checked);
|
||||||
|
if (selected is null)
|
||||||
|
{
|
||||||
|
MessageBox.Show("No MFA option selected", "None selected", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Serilog.Log.Logger.Debug("Selected: {@DebugInfo}", new { isSelected = selected is not null, name = selected?.Name, value = selected?.Tag });
|
Serilog.Log.Logger.Information("Selected: {@DebugInfo}", new { isSelected = selected is not null, name = selected?.Name, value = selected?.Tag });
|
||||||
|
|
||||||
SelectedName = selected.Name;
|
SelectedName = selected.Name;
|
||||||
SelectedValue = (string)selected.Tag;
|
SelectedValue = (string)selected.Tag;
|
||||||
|
|||||||
@ -17,7 +17,7 @@ namespace LibationWinForms.Login
|
|||||||
public string Get2faCode()
|
public string Get2faCode()
|
||||||
{
|
{
|
||||||
using var dialog = new _2faCodeDialog();
|
using var dialog = new _2faCodeDialog();
|
||||||
if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
|
if (showDialog(dialog))
|
||||||
return dialog.Code;
|
return dialog.Code;
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -25,7 +25,7 @@ namespace LibationWinForms.Login
|
|||||||
public string GetCaptchaAnswer(byte[] captchaImage)
|
public string GetCaptchaAnswer(byte[] captchaImage)
|
||||||
{
|
{
|
||||||
using var dialog = new CaptchaDialog(captchaImage);
|
using var dialog = new CaptchaDialog(captchaImage);
|
||||||
if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
|
if (showDialog(dialog))
|
||||||
return dialog.Answer;
|
return dialog.Answer;
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -33,7 +33,7 @@ namespace LibationWinForms.Login
|
|||||||
public (string name, string value) GetMfaChoice(MfaConfig mfaConfig)
|
public (string name, string value) GetMfaChoice(MfaConfig mfaConfig)
|
||||||
{
|
{
|
||||||
using var dialog = new MfaDialog(mfaConfig);
|
using var dialog = new MfaDialog(mfaConfig);
|
||||||
if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
|
if (showDialog(dialog))
|
||||||
return (dialog.SelectedName, dialog.SelectedValue);
|
return (dialog.SelectedName, dialog.SelectedValue);
|
||||||
return (null, null);
|
return (null, null);
|
||||||
}
|
}
|
||||||
@ -41,7 +41,7 @@ namespace LibationWinForms.Login
|
|||||||
public (string email, string password) GetLogin()
|
public (string email, string password) GetLogin()
|
||||||
{
|
{
|
||||||
using var dialog = new AudibleLoginDialog(_account);
|
using var dialog = new AudibleLoginDialog(_account);
|
||||||
if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
|
if (showDialog(dialog))
|
||||||
return (dialog.Email, dialog.Password);
|
return (dialog.Email, dialog.Password);
|
||||||
return (null, null);
|
return (null, null);
|
||||||
}
|
}
|
||||||
@ -49,7 +49,15 @@ namespace LibationWinForms.Login
|
|||||||
public void ShowApprovalNeeded()
|
public void ShowApprovalNeeded()
|
||||||
{
|
{
|
||||||
using var dialog = new ApprovalNeededDialog();
|
using var dialog = new ApprovalNeededDialog();
|
||||||
dialog.ShowDialog();
|
showDialog(dialog);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <returns>True if ShowDialog's DialogResult == OK</returns>
|
||||||
|
private static bool showDialog(System.Windows.Forms.Form dialog)
|
||||||
|
{
|
||||||
|
var result = dialog.ShowDialog();
|
||||||
|
Serilog.Log.Logger.Debug("{@DebugInfo}", new { DialogResult = result });
|
||||||
|
return result == System.Windows.Forms.DialogResult.OK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user