1using CommunityToolkit.Mvvm.ComponentModel;
2using CommunityToolkit.Mvvm.Input;
28 [NotifyCanExecuteChangedFor(nameof(ChangePasswordCommand))]
29 private string oldPassword =
string.Empty;
38 [NotifyCanExecuteChangedFor(nameof(ChangePasswordCommand))]
39 private string newPassword =
string.Empty;
47 [NotifyCanExecuteChangedFor(nameof(ChangePasswordCommand))]
48 private string newPassword2 =
string.Empty;
55 [NotifyCanExecuteChangedFor(nameof(ChangePasswordCommand))]
56 private bool incorrectPasswordAlertShown =
false;
61 public bool CanChangePassword => this.NewPasswordStrength == PasswordStrength.Strong && this.NewPasswordMatchesRetypedNewPassword && this.IsConnected && !this.IsBusy;
71 public bool NewPasswordsMatch =>
string.IsNullOrEmpty(this.NewPassword) ?
string.IsNullOrEmpty(this.NewPassword2) :
string.Equals(this.NewPassword, this.NewPassword2, StringComparison.Ordinal);
86 public bool NewPasswordMatchesRetypedNewPassword =>
string.IsNullOrEmpty(this.NewPassword) ?
string.IsNullOrEmpty(this.NewPassword2) :
string.Equals(this.NewPassword, this.NewPassword2, StringComparison.Ordinal);
95 await base.OnInitialize();
96 this.NotifyCommandsCanExecuteChanged();
102 return MainThread.InvokeOnMainThreadAsync(async () =>
104 await base.XmppService_ConnectionStateChanged(Sender, NewState);
106 this.NotifyCommandsCanExecuteChanged();
113 base.SetIsBusy(IsBusy);
114 this.NotifyCommandsCanExecuteChanged();
117 private void NotifyCommandsCanExecuteChanged()
119 this.ChangePasswordCommand.NotifyCanExecuteChanged();
126 private async Task ChangePassword()
128 if (!
string.IsNullOrEmpty(this.OldPassword) && this.CanChangePassword)
144 ServiceRef.TagProfile.LocalPassword = this.NewPassword;
161 this.OldPassword =
string.Empty;
163 long PasswordAttemptCounter = await
App.GetCurrentPasswordCounter();
The Application class, representing an instance of the Neuro-Access app.
static async Task< bool > CheckPasswordAndUnblockUser(string Password)
Check the Password and reset the blocking counters if it matches
static async Task CheckUserBlocking()
Verify if the user is blocked and show an alert
const int FirstMaxPasswordAttempts
Maximum password enetring attempts, first interval
A set of never changing property constants and helpful values.
Base class that references services in the app.
static ILogService LogService
Log service.
static IUiService UiService
Service serializing and managing UI-related tasks.
static ITagProfile TagProfile
TAG Profile service.
static ICryptoService CryptoService
Crypto service.
static IStringLocalizer Localizer
Localization service
static IXmppService XmppService
The XMPP service for XMPP communication.
virtual async Task GoBack()
Method called when user wants to navigate to the previous screen.
View model for the ChangePasswordPage page.
string LocalizedValidationError
Localized validation error message.
override Task XmppService_ConnectionStateChanged(object? Sender, XmppState NewState)
Listens to connection state changes from the XMPP server.
bool IsPassword2NotValid
If Second New password entry is not valid.
override void SetIsBusy(bool IsBusy)
Sets the IsBusy property.
bool NewPasswordsMatch
Gets the value indicating whether the entered NewPassword is the same as the entered NewPassword2.
bool CanChangePassword
If new password can be used.
override async Task OnInitialize()
Method called when view is initialized for the first time. Use this method to implement registration ...
bool NewPasswordMatchesRetypedNewPassword
If both new passwords match.
PasswordStrength NewPasswordStrength
Strength of new password
bool IsPassword1NotValid
If First New Password entry is not valid.
ChangePasswordViewModel()
View model for the ChangePasswordPage page.
static string GetLocalizedValidationError(PasswordStrength PasswordStrength)
Gets a localized error message, given a Password strength.
A view model that holds the XMPP state.
PasswordStrength ValidatePasswordStrength(string? Password)
Validates if the Password is strong enough.
string? Account
The account name for this profile
void SetAccount(string AccountName, string ClientPasswordHash, string ClientPasswordHashMethod)
Set the account name and password for a new account.
PasswordStrength
Represents a result of validating password strength.
XmppState
State of XMPP connection.