diff --git a/Borepin/Borepin/PageModel/AddServerProcess/LoginPasswordPageModel.cs b/Borepin/Borepin/PageModel/AddServerProcess/LoginPasswordPageModel.cs index 0c08bda..77f8b9d 100644 --- a/Borepin/Borepin/PageModel/AddServerProcess/LoginPasswordPageModel.cs +++ b/Borepin/Borepin/PageModel/AddServerProcess/LoginPasswordPageModel.cs @@ -4,6 +4,7 @@ using Borepin.Service.BFFH; using Borepin.Service.Connections; using Prism.Commands; using Prism.Navigation; +using Prism.Services; using System; using System.Threading.Tasks; using System.Windows.Input; @@ -15,13 +16,16 @@ namespace Borepin.PageModel.AddServerProcess #region Private Properties private readonly IBFFHService _BFFHService; private readonly IConnectionService _ConnectionService; + private readonly IPageDialogService _PageDialogService; #endregion #region Constructors - public LoginPasswordPageModel(INavigationService navigationService, IBFFHService bffhService, IConnectionService connectionService) : base(navigationService) + public LoginPasswordPageModel(INavigationService navigationService, IBFFHService bffhService, IConnectionService connectionService, IPageDialogService pageDialogService) : base(navigationService) { _BFFHService = bffhService; _ConnectionService = connectionService; + _PageDialogService = pageDialogService; + AuthenticateCommand = new DelegateCommand(async () => await AuthenticateCommandExecuted()); @@ -64,11 +68,19 @@ namespace Borepin.PageModel.AddServerProcess private async Task AuthenticateCommandExecuted() { + IsBusy = true; + Connection connection_update = _BFFHService.ActiveConnection; connection_update.Username = Username; - await _BFFHService.Authenticate(connection_update, Password); + if(!await _BFFHService.Authenticate(connection_update, Password)) + { + await _PageDialogService.DisplayAlertAsync("Connection failed", "Unable to authenticate to server.", "Ok"); + + IsBusy = false; + return; + } try { @@ -76,7 +88,7 @@ namespace Borepin.PageModel.AddServerProcess } catch (ArgumentException) { - + // Could be better catched } await _ConnectionService.LogConnect(_BFFHService.ActiveConnection); diff --git a/Borepin/Borepin/PageModel/ServerPageModel.cs b/Borepin/Borepin/PageModel/ServerPageModel.cs index 7fed943..523f7b7 100644 --- a/Borepin/Borepin/PageModel/ServerPageModel.cs +++ b/Borepin/Borepin/PageModel/ServerPageModel.cs @@ -91,7 +91,14 @@ namespace Borepin.PageModel IsBusy = false; return; } - await _BFFHService.Authenticate(); + + if(!await _BFFHService.Authenticate()) + { + await _PageDialogService.DisplayAlertAsync("Connection failed", "Unable to authenticate to server.", "Ok"); + + IsBusy = false; + return; + } IsConnected = true; } diff --git a/Borepin/Borepin/PageModel/SetUpProcess/WelcomePageModel.cs b/Borepin/Borepin/PageModel/SetUpProcess/WelcomePageModel.cs index 4e32f11..8f82f79 100644 --- a/Borepin/Borepin/PageModel/SetUpProcess/WelcomePageModel.cs +++ b/Borepin/Borepin/PageModel/SetUpProcess/WelcomePageModel.cs @@ -31,7 +31,8 @@ namespace Borepin.PageModel.SetUpProcess } private async void NextCommandCommandExecuted(object obj) { - INavigationResult result = await _NavigationService.NavigateAsync("SetUpProcess_ScanPage"); + //INavigationResult result = await _NavigationService.NavigateAsync("SetUpProcess_ScanPage"); + INavigationResult result = await _NavigationService.NavigateAsync("AddServerProcess_HostSelectPage"); if (!result.Success) { System.Diagnostics.Debugger.Break(); diff --git a/Borepin/Borepin/Resources/Text/TextResource.Designer.cs b/Borepin/Borepin/Resources/Text/TextResource.Designer.cs index a6b3603..8491aaa 100644 --- a/Borepin/Borepin/Resources/Text/TextResource.Designer.cs +++ b/Borepin/Borepin/Resources/Text/TextResource.Designer.cs @@ -79,7 +79,7 @@ namespace Borepin.Resources.Text { } /// - /// Looks up a localized string similar to Start working. + /// Looks up a localized string similar to Begin working. /// internal static string SetUp_WelcomePage_Button { get { @@ -88,7 +88,7 @@ namespace Borepin.Resources.Text { } /// - /// Looks up a localized string similar to Hier muss ein kurzer Text hin was FabAccess ist und was man damit machen kann. + /// Looks up a localized string similar to Automate your Space with FabAccess. /// internal static string SetUp_WelcomePage_Text { get { diff --git a/Borepin/Borepin/Resources/Text/TextResource.resx b/Borepin/Borepin/Resources/Text/TextResource.resx index e90605a..63638c2 100644 --- a/Borepin/Borepin/Resources/Text/TextResource.resx +++ b/Borepin/Borepin/Resources/Text/TextResource.resx @@ -124,10 +124,10 @@ Wenn du dieses Logo siehst, dann kannst du es scannen - Start working + Begin working - Hier muss ein kurzer Text hin was FabAccess ist und was man damit machen kann + Automate your Space with FabAccess Welcome diff --git a/Borepin/Borepin/Service/BFFH/BFFHService.cs b/Borepin/Borepin/Service/BFFH/BFFHService.cs index f97b948..e368396 100644 --- a/Borepin/Borepin/Service/BFFH/BFFHService.cs +++ b/Borepin/Borepin/Service/BFFH/BFFHService.cs @@ -75,20 +75,21 @@ namespace Borepin.Service.BFFH { string password = await _CredentialService.GetPasswordAsync(ActiveConnection); - await _Connection.Auth("PLAIN", new Dictionary { { "Username", ActiveConnection.Username }, { "Password", password } }); - - return await Task.FromResult(true); + return await _Connection.Auth("PLAIN", new Dictionary { { "Username", ActiveConnection.Username }, { "Password", password } }); } public async Task Authenticate(Connection connection, string password) { - await _Connection.Auth("PLAIN", new Dictionary { { "Username", ActiveConnection.Username }, { "Password", password } }).ConfigureAwait(false); + bool result = await _Connection.Auth("PLAIN", new Dictionary { { "Username", ActiveConnection.Username }, { "Password", password } }); - await _CredentialService.AddCredentialsAsync(connection, password); + if(result == true) + { + await _CredentialService.AddCredentialsAsync(connection, password); - ActiveConnection = connection; + ActiveConnection = connection; + } - return await Task.FromResult(true); + return result; } public Task GetMachineSystemInterface() diff --git a/FabAccessAPI/Connection.cs b/FabAccessAPI/Connection.cs index 952b313..98028db 100644 --- a/FabAccessAPI/Connection.cs +++ b/FabAccessAPI/Connection.cs @@ -40,10 +40,10 @@ namespace FabAccessAPI /// The desired authentication mechanism /// Key-Value data specific to the mechanism /// - public async Task Auth(string mech, Dictionary kvs, CancellationToken cancellationToken_ = default) + public async Task Auth(string mech, Dictionary kvs, CancellationToken cancellationToken_ = default) { // _bootstrapCap = await _bootstrapCap.Unwrap(); - var authCap = await _bootstrapCap.AuthenticationSystem(cancellationToken_).ConfigureAwait(false); + var authCap = await _bootstrapCap.AuthenticationSystem(cancellationToken_); _auth = new Auth(authCap); var mechs = await _auth.GetMechanisms(); //_Log.Debug($"The Server supports the following auth mechs: {string.Join(", ", mechs)}"); @@ -53,7 +53,7 @@ namespace FabAccessAPI throw new UnsupportedMechanismException(); } - await _auth.Authenticate(mech, kvs); + return await _auth.Authenticate(mech, kvs); } ///