private void Send(object sender, RoutedEventArgs eventSend) { if (ValidatePassword() && ValidateCode()) { try { InstanceContext instanceContext = new InstanceContext(this); PlayerManagerClient changePassword = new PlayerManagerClient(instanceContext); changePassword.ChangePassword(emailAccount, Security.Encrypt(pbNewPassword.Password)); if (response) { System.Windows.Forms.MessageBox.Show(Properties.Resources.PasswordChangedDetails, Properties.Resources.PasswordChanged , MessageBoxButtons.OK, MessageBoxIcon.Information); } else { System.Windows.Forms.MessageBox.Show(Properties.Resources.ErrorDataBaseDetails, Properties.Resources.ErrorDataBase , MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (EndpointNotFoundException exception) { TelegramBot.SendToTelegram(exception); LogException.Log(this, exception); LogException.ErrorConnectionService(); } MainWindow main = new MainWindow(); main.Show(); this.Close(); } }
/// <summary> /// Crea una solicitud al servidor para actualizar la contraseña asociada a un <c>Jugador</c> /// </summary> /// <param name="player"></param> /// <exception> /// Esta excepcion puede retornar una excepcion tipo EndpointNotFoundException /// </exception> public static void ChangePassword(Jugador player) { InstanceContext instanceContext = new InstanceContext(new PlayerCallbackHandler()); PlayerManagerClient server = new PlayerManagerClient(instanceContext); try { server.ChangePassword(player.Apodo, player.Contrasenia); } catch (EndpointNotFoundException) { MessageBox.Show("No se ha podido conectar a la Base de datos, intentar mas tarde"); } }
public void PasswordChangeResult_ReturnErrorChanging_PasswordChangeResult() { try { var baseAddress = new Uri("net.tcp://*****:*****@gmail.com", PinConfirmacion = "1234", PreguntaRecuperacion = "testquestion?", RespuestaConfirmacion = "testanswer", }; playerClient.ChangePassword(testPlayer.Apodo, "newpassword"); PlayerCallbackHandler playerHandler = new PlayerCallbackHandler(); PasswordChangeResult result = playerHandler.passwordChangeResult; Assert.AreEqual(result, PasswordChangeResult.ErrorChanging); } catch (EndpointNotFoundException) { playerClient.Abort(); } catch (CommunicationException) { playerClient.Abort(); } }
private void ChangeAccountPassword(object sender, RoutedEventArgs routedEventArgs) { imgErrorConfirmationPassword.Visibility = Visibility.Hidden; imgErrorCurrentPassword.Visibility = Visibility.Hidden; imgErrorNewPassword.Visibility = Visibility.Hidden; pbConfirmationPassword.BorderBrush = Brushes.Transparent; pbPassword.BorderBrush = Brushes.Transparent; pbNewPassword.BorderBrush = Brushes.Transparent; isValidNewPassword = false; ValidatePassword(); ValidateNewPassword(); if (isValidPassword && isValidNewPassword) { string passwordEncrypt = Security.Encrypt(pbNewPassword.Password); try { InstanceContext instanceContext = new InstanceContext(this); PlayerManagerClient playerManager = new PlayerManagerClient(instanceContext); playerManager.ChangePassword(account.Email, passwordEncrypt); if (responseBoolean) { OpenMessageBox(Properties.Resources.ChangePasswordMessage, Properties.Resources.ChangePasswordMessageTitle, (MessageBoxImage)System.Windows.Forms.MessageBoxIcon.Information); } else { OpenMessageBox(Properties.Resources.NoChangePasswordMessage, Properties.Resources.ChangePasswordMessageTitle, (MessageBoxImage)System.Windows.Forms.MessageBoxIcon.Error); } ModifyAccount modifyAccount = new ModifyAccount(); modifyAccount.ObtainAccount(); modifyAccount.Show(); this.Close(); } catch (EndpointNotFoundException exception) { TelegramBot.SendToTelegram(exception); LogException.Log(this, exception); LogException.ErrorConnectionService(); } } else { OpenMessageBox(Properties.Resources.IncorrectDataMessage, Properties.Resources.IncorrectDataMessageTitle, (MessageBoxImage)System.Windows.Forms.MessageBoxIcon.Warning); } }