From 85ae6767ae0e2fc29587ee9cf4813acd2f5cecac Mon Sep 17 00:00:00 2001 From: TheJoKlLa Date: Thu, 19 Jan 2023 01:31:07 +0100 Subject: [PATCH] Fixed: InvalidCredentials Alert --- .../AddServerProcess/AuthPlainPageModel.cs | 18 ++++++++- Borepin/Borepin/PageModel/ScanURNPageModel.cs | 2 +- Borepin/Borepin/PageModel/StartPageModel.cs | 40 +++++++++++++------ .../Resources/Text/TextResource.Designer.cs | 22 +++++++++- .../Borepin/Resources/Text/TextResource.resx | 8 +++- 5 files changed, 72 insertions(+), 18 deletions(-) diff --git a/Borepin/Borepin/PageModel/AddServerProcess/AuthPlainPageModel.cs b/Borepin/Borepin/PageModel/AddServerProcess/AuthPlainPageModel.cs index 4a323b9..81612c4 100644 --- a/Borepin/Borepin/PageModel/AddServerProcess/AuthPlainPageModel.cs +++ b/Borepin/Borepin/PageModel/AddServerProcess/AuthPlainPageModel.cs @@ -79,6 +79,12 @@ namespace Borepin.PageModel.AddServerProcess public async Task AuthenticateCommandExecute() { IsBusy = true; + if(Username == null || Username == String.Empty || Password == null || Password == String.Empty) + { + IsBusy = false; + return; + } + Username = Username.Trim(); _ConnectionData = new ConnectionData() @@ -116,6 +122,16 @@ namespace Borepin.PageModel.AddServerProcess }); return; } + catch (InvalidCredentialsException) + { + Device.BeginInvokeOnMainThread(async () => + { + await _PageDialogService.DisplayAlertAsync(Resources.Text.TextResource.ALERT_ConnectionFailed, Resources.Text.TextResource.ALERT_CredentialsInvalid, Resources.Text.TextResource.OK).ConfigureAwait(false); + + IsBusy = false; + }); + return; + } catch (AuthenticationFailedException) { Device.BeginInvokeOnMainThread(async () => @@ -126,7 +142,7 @@ namespace Borepin.PageModel.AddServerProcess }); return; } - catch(Exception) + catch(Exception ex) { Device.BeginInvokeOnMainThread(async () => { diff --git a/Borepin/Borepin/PageModel/ScanURNPageModel.cs b/Borepin/Borepin/PageModel/ScanURNPageModel.cs index 7974fa4..e047c23 100644 --- a/Borepin/Borepin/PageModel/ScanURNPageModel.cs +++ b/Borepin/Borepin/PageModel/ScanURNPageModel.cs @@ -109,7 +109,7 @@ namespace Borepin.PageModel { Device.BeginInvokeOnMainThread(async () => { - await _PageDialogService.DisplayAlertAsync(Resources.Text.TextResource.ALERT, Resources.Text.TextResource.Alert_QRInvalid, Resources.Text.TextResource.OK).ConfigureAwait(false); + await _PageDialogService.DisplayAlertAsync(Resources.Text.TextResource.ALERT, Resources.Text.TextResource.ALERT_QRInvalid, Resources.Text.TextResource.OK).ConfigureAwait(false); IsScanning = true; }); return; diff --git a/Borepin/Borepin/PageModel/StartPageModel.cs b/Borepin/Borepin/PageModel/StartPageModel.cs index 646d0f4..4c7bfef 100644 --- a/Borepin/Borepin/PageModel/StartPageModel.cs +++ b/Borepin/Borepin/PageModel/StartPageModel.cs @@ -69,23 +69,37 @@ namespace Borepin.PageModel } }); } - catch(Exception ex) + catch (ConnectingFailedException) { - if (ex is AuthenticationFailedException) + Device.BeginInvokeOnMainThread(async () => { - Device.BeginInvokeOnMainThread(async () => - { - await _PageDialogService.DisplayAlertAsync(Resources.Text.TextResource.ALERT_ConnectionFailed, Resources.Text.TextResource.ALERT_AuthServer, Resources.Text.TextResource.OK).ConfigureAwait(false); - }); - } - else if (ex is ConnectingFailedException) + await _PageDialogService.DisplayAlertAsync(Resources.Text.TextResource.ALERT_ConnectionFailed, Resources.Text.TextResource.ALERT_UnableServer, Resources.Text.TextResource.OK).ConfigureAwait(false); + }); + } + catch (AuthenticationFailedException) + { + Device.BeginInvokeOnMainThread(async () => { - Device.BeginInvokeOnMainThread(async () => - { - await _PageDialogService.DisplayAlertAsync(Resources.Text.TextResource.ALERT_ConnectionFailed, Resources.Text.TextResource.ALERT_UnableServer, Resources.Text.TextResource.OK).ConfigureAwait(false); - }); - } + await _PageDialogService.DisplayAlertAsync(Resources.Text.TextResource.ALERT_ConnectionFailed, Resources.Text.TextResource.ALERT_AuthServer, Resources.Text.TextResource.OK).ConfigureAwait(false); + }); + } + catch (InvalidCredentialsException) + { + Device.BeginInvokeOnMainThread(async () => + { + await _PageDialogService.DisplayAlertAsync(Resources.Text.TextResource.ALERT_ConnectionFailed, Resources.Text.TextResource.ALERT_CredentialsInvalid, Resources.Text.TextResource.OK).ConfigureAwait(false); + }); + } + catch (Exception) + { + Device.BeginInvokeOnMainThread(async () => + { + await _PageDialogService.DisplayAlertAsync(Resources.Text.TextResource.ALERT_UnexpectedError, Resources.Text.TextResource.ALERT_UnableServer, Resources.Text.TextResource.OK).ConfigureAwait(false); + }); + } + if (_API.IsConnected == false) + { Device.BeginInvokeOnMainThread(async () => { INavigationResult result = await _NavigationService.NavigateAsync("/MainPage/NavigationPage/ServerListPage").ConfigureAwait(false); diff --git a/Borepin/Borepin/Resources/Text/TextResource.Designer.cs b/Borepin/Borepin/Resources/Text/TextResource.Designer.cs index 1dc0baf..3b7573e 100644 --- a/Borepin/Borepin/Resources/Text/TextResource.Designer.cs +++ b/Borepin/Borepin/Resources/Text/TextResource.Designer.cs @@ -188,6 +188,15 @@ namespace Borepin.Resources.Text { } } + /// + /// Sucht eine lokalisierte Zeichenfolge, die Credentials are invalid. ähnelt. + /// + internal static string ALERT_CredentialsInvalid { + get { + return ResourceManager.GetString("ALERT_CredentialsInvalid", resourceCulture); + } + } + /// /// Sucht eine lokalisierte Zeichenfolge, die Connection already exist. Please delete old Connection before adding the new Connection. ähnelt. /// @@ -209,9 +218,9 @@ namespace Borepin.Resources.Text { /// /// Sucht eine lokalisierte Zeichenfolge, die QR Code is invalid ähnelt. /// - internal static string Alert_QRInvalid { + internal static string ALERT_QRInvalid { get { - return ResourceManager.GetString("Alert_QRInvalid", resourceCulture); + return ResourceManager.GetString("ALERT_QRInvalid", resourceCulture); } } @@ -450,6 +459,15 @@ namespace Borepin.Resources.Text { } } + /// + /// Sucht eine lokalisierte Zeichenfolge, die Unlock ähnelt. + /// + internal static string MachinePage_Unlock { + get { + return ResourceManager.GetString("MachinePage_Unlock", resourceCulture); + } + } + /// /// Sucht eine lokalisierte Zeichenfolge, die Use ähnelt. /// diff --git a/Borepin/Borepin/Resources/Text/TextResource.resx b/Borepin/Borepin/Resources/Text/TextResource.resx index fd73670..faa73d3 100644 --- a/Borepin/Borepin/Resources/Text/TextResource.resx +++ b/Borepin/Borepin/Resources/Text/TextResource.resx @@ -161,13 +161,16 @@ You can also put down several servers and then connect to the desired server. Connection failed + + Credentials are invalid. + Connection already exist. Please delete old Connection before adding the new Connection. Password is invalid. - + QR Code is invalid @@ -249,6 +252,9 @@ Ask in your Space if you can be trained on the machine to be unlocked for the ma Open Wiki + + Unlock + Use