1using CommunityToolkit.Mvvm.ComponentModel;
2using CommunityToolkit.Mvvm.Input;
30 [NotifyCanExecuteChangedFor(nameof(ChangePasswordCommand))]
31 private string oldPassword =
string.Empty;
40 [NotifyCanExecuteChangedFor(nameof(ChangePasswordCommand))]
41 private string newPassword =
string.Empty;
49 [NotifyCanExecuteChangedFor(nameof(ChangePasswordCommand))]
50 private string newPassword2 =
string.Empty;
57 [NotifyCanExecuteChangedFor(nameof(ChangePasswordCommand))]
58 private bool incorrectPasswordAlertShown =
false;
63 public bool CanChangePassword => this.NewPasswordStrength == PasswordStrength.Strong && this.NewPasswordMatchesRetypedNewPassword && this.IsConnected && !this.IsBusy;
73 public bool NewPasswordsMatch =>
string.IsNullOrEmpty(this.NewPassword) ?
string.IsNullOrEmpty(this.NewPassword2) :
string.Equals(this.NewPassword, this.NewPassword2, StringComparison.Ordinal);
88 public bool NewPasswordMatchesRetypedNewPassword =>
string.IsNullOrEmpty(this.NewPassword) ?
string.IsNullOrEmpty(this.NewPassword2) :
string.Equals(this.NewPassword, this.NewPassword2, StringComparison.Ordinal);
118 PasswordStrength.Strong =>
string.Empty,
119 _ =>
throw new NotImplementedException()
125 await base.OnInitializeAsync();
126 this.NotifyCommandsCanExecuteChanged();
132 return MainThread.InvokeOnMainThreadAsync(async () =>
134 await base.XmppService_ConnectionStateChanged(Sender, NewState);
136 this.NotifyCommandsCanExecuteChanged();
143 base.SetIsBusy(IsBusy);
144 this.NotifyCommandsCanExecuteChanged();
147 private void NotifyCommandsCanExecuteChanged()
149 this.ChangePasswordCommand.NotifyCanExecuteChanged();
156 private async Task ChangePassword()
158 if (!
string.IsNullOrEmpty(this.OldPassword) && this.CanChangePassword)
160 if (await this.authenticationService.CheckPasswordAndUnblockUserAsync(
this.OldPassword))
174 ServiceRef.TagProfile.LocalPassword = this.NewPassword;
191 this.OldPassword =
string.Empty;
193 long PasswordAttemptCounter = await this.authenticationService.GetCurrentPasswordCounterAsync();
200 await this.authenticationService.CheckUserBlockingAsync();
const int FirstMaxPasswordAttempts
Maximum password enetring attempts, first interval
const int MaxPasswordIdenticalSymbols
Maximum number of identical symbols in a password.
const int MinPasswordLength
Minimum length for password
const int MinPasswordSymbolsFromDifferentClasses
Minimum number of symbols from at least two character classes (digits, letters, other) in a password.
const int MaxPasswordSequencedSymbols
Maximum number of sequenced symbols in a password.
A set of never changing property constants and helpful values.
A strongly-typed resource class, for looking up localized strings, etc.
static string PasswordWithNotEnoughLettersOrDigits
Looks up a localized string similar to You must also use at least {0} letters or digits....
static string PasswordWithNotEnoughDigitsOrSigns
Looks up a localized string similar to You must also use at least {0} digits or symbols....
static string PasswordWithTooManyIdenticalSymbols
Looks up a localized string similar to A PIN must not contain more than {0} identical symbols....
static string PasswordContainsName
Looks up a localized string similar to A PIN must not contain any word from the identity names....
static string PasswordContainsAddress
Looks up a localized string similar to A PIN must not contain any word from the identity address....
static string PasswordContainsPhoneNumber
Looks up a localized string similar to A PIN must not contain the identity phone number....
static string PasswordIsInvalid
Looks up a localized string similar to PIN is invalid. You have {0} remaining attempts....
static string PasswordChanged
Looks up a localized string similar to PIN has been successfully changed..
static string PasswordContainsPersonalNumber
Looks up a localized string similar to A PIN must not contain the identity personal number....
static string UnableToChangePassword
Looks up a localized string similar to Unable to change network password..
static string PasswordWithTooManySequencedSymbols
Looks up a localized string similar to A PIN must not contain more than {0} sequenced symbols,...
static string PasswordWithNotEnoughDigitsLettersSigns
Looks up a localized string similar to At least {0} letters, digits or symbols must be used....
static string PasswordContainsEMail
Looks up a localized string similar to A PIN must not contain the identity e-mail address....
static string SuccessTitle
Looks up a localized string similar to Success.
static string PasswordTooShort
Looks up a localized string similar to PIN length must be at least {0} characters....
static string PasswordWithNotEnoughLettersOrSigns
Looks up a localized string similar to You must also use at least {0} letters or symbols....
static string ErrorTitle
Looks up a localized string similar to An error has occurred.
Base class that references services in the app.
static IServiceProvider Provider
The service provider for the app. This is set before the app is started, and will be used to resolve ...
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 IReportingStringLocalizer 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 async Task OnInitializeAsync()
Method called when view is initialized for the first time. Use this method to implement registration ...
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.
static string GetLocalizedValidationError(PasswordStrength PasswordStrength)
Gets a localized error message, given a Password strength.
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.
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.