|
@@ -15,7 +15,7 @@ using System.Windows.Controls;
|
|
|
|
|
|
namespace InABox.Poster.MYOB;
|
|
|
|
|
|
-public class MYOBConnectionData(ApiConfiguration configuration, CompanyFileService cfService)
|
|
|
+public class MYOBConnectionData(ApiConfiguration configuration, CompanyFileService cfService, IOAuthKeyService authKey)
|
|
|
{
|
|
|
public ApiConfiguration Configuration { get; set; } = configuration;
|
|
|
|
|
@@ -26,6 +26,8 @@ public class MYOBConnectionData(ApiConfiguration configuration, CompanyFileServi
|
|
|
public CompanyFileCredentials? CompanyFileCredentials { get; set; }
|
|
|
|
|
|
public CompanyFileWithResources? ActiveCompanyFile { get; set; }
|
|
|
+
|
|
|
+ public IOAuthKeyService AuthKey { get; set; } = authKey;
|
|
|
}
|
|
|
|
|
|
public partial class MYOBPosterEngine<TPostable> :
|
|
@@ -56,25 +58,27 @@ public partial class MYOBPosterEngine<TPostable> :
|
|
|
var window = new Window
|
|
|
{
|
|
|
Width = 800,
|
|
|
- Height = 600
|
|
|
+ Height = 600,
|
|
|
+ Title = "Sign in to MYOB"
|
|
|
};
|
|
|
|
|
|
string? resultCode = null;
|
|
|
- var browser = new WebBrowser();
|
|
|
- browser.Navigated += (o, e) =>
|
|
|
+ var browser = new System.Windows.Forms.WebBrowser();
|
|
|
+ browser.DocumentTitleChanged += (o, e) =>
|
|
|
{
|
|
|
- dynamic doc = browser.Document;
|
|
|
- var htmlText = doc.documentElement.InnerHtml as string;
|
|
|
+ var htmlText = browser.DocumentText;
|
|
|
if(htmlText is not null)
|
|
|
{
|
|
|
var match = CodeRegex().Match(htmlText);
|
|
|
if (match.Success)
|
|
|
{
|
|
|
resultCode = match.Groups[1].Value;
|
|
|
+ window.DialogResult = true;
|
|
|
window.Close();
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
+
|
|
|
browser.Navigate(url);
|
|
|
window.Content = browser;
|
|
|
if(window.ShowDialog() == true)
|
|
@@ -115,7 +119,7 @@ public partial class MYOBPosterEngine<TPostable> :
|
|
|
|
|
|
var cfService = new CompanyFileService(configuration, null, keystore);
|
|
|
|
|
|
- _connectionData = new MYOBConnectionData(configuration, cfService);
|
|
|
+ _connectionData = new MYOBConnectionData(configuration, cfService, keystore);
|
|
|
|
|
|
return _connectionData;
|
|
|
}
|