示例#1
0
        private async Task ExecuteRecoverPasswordAsync(object parameter)
        {
            if (String.IsNullOrWhiteSpace(RecoveryCode))
            {
                MessageBoxHelper.ShowErrorMessageBox("Wprowadź kod resetujący hasło otrzymany w wiadomości e-mail.");
                return;
            }

            Int32.TryParse(RecoveryCode, out int userCode);
            if (userCode == _recoveryCode)
            {
                await _longRunningOperationHelper.ProceedLongRunningOperationAsync(async() =>
                {
                    string password       = _loginService.GeneratePassword();
                    string hashedPassword = _loginService.HashPassword(password);
                    _user.HashedPassword  = hashedPassword;
                    await _usersRepository.InsertOrReplaceAsync(_user);
                    await _mailingService.SendEmailWithNewPasswordAsync(Email, password);
                });

                MessageBoxHelper.ShowMessageBox("Twoje hasło zostało zresetowane. Na podany adres e-mail zostało wysłane nowe hasło.");
                _window.Close();
            }
            else
            {
                MessageBoxHelper.ShowErrorMessageBox("Wprowadzono niepoprawny kod resetujący hasło.");
            }
        }