More Usebility

This commit is contained in:
TheJoKlLa 2021-09-21 23:59:14 +02:00
parent 4822373d28
commit 0c5bf80654
7 changed files with 40 additions and 19 deletions

View File

@ -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);

View File

@ -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;
}

View File

@ -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();

View File

@ -79,7 +79,7 @@ namespace Borepin.Resources.Text {
}
/// <summary>
/// Looks up a localized string similar to Start working.
/// Looks up a localized string similar to Begin working.
/// </summary>
internal static string SetUp_WelcomePage_Button {
get {
@ -88,7 +88,7 @@ namespace Borepin.Resources.Text {
}
/// <summary>
/// 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.
/// </summary>
internal static string SetUp_WelcomePage_Text {
get {

View File

@ -124,10 +124,10 @@
<value>Wenn du dieses Logo siehst, dann kannst du es scannen</value>
</data>
<data name="SetUp_WelcomePage_Button" xml:space="preserve">
<value>Start working</value>
<value>Begin working</value>
</data>
<data name="SetUp_WelcomePage_Text" xml:space="preserve">
<value>Hier muss ein kurzer Text hin was FabAccess ist und was man damit machen kann</value>
<value>Automate your Space with FabAccess</value>
</data>
<data name="SetUp_WelcomePage_Title" xml:space="preserve">
<value>Welcome</value>

View File

@ -75,20 +75,21 @@ namespace Borepin.Service.BFFH
{
string password = await _CredentialService.GetPasswordAsync(ActiveConnection);
await _Connection.Auth("PLAIN", new Dictionary<string, object> { { "Username", ActiveConnection.Username }, { "Password", password } });
return await Task.FromResult(true);
return await _Connection.Auth("PLAIN", new Dictionary<string, object> { { "Username", ActiveConnection.Username }, { "Password", password } });
}
public async Task<bool> Authenticate(Connection connection, string password)
{
await _Connection.Auth("PLAIN", new Dictionary<string, object> { { "Username", ActiveConnection.Username }, { "Password", password } }).ConfigureAwait(false);
bool result = await _Connection.Auth("PLAIN", new Dictionary<string, object> { { "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<IMachineSystem> GetMachineSystemInterface()

View File

@ -40,10 +40,10 @@ namespace FabAccessAPI
/// <param name="mech">The desired authentication mechanism</param>
/// <param name="kvs">Key-Value data specific to the mechanism</param>
/// <returns></returns>
public async Task Auth(string mech, Dictionary<string, object> kvs, CancellationToken cancellationToken_ = default)
public async Task<bool> Auth(string mech, Dictionary<string, object> 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);
}
/// <summary>