80 lines
2.2 KiB
C#
80 lines
2.2 KiB
C#
// /************************************************************************
|
|
// * @file PasswordChangeDialog.xaml.cs
|
|
// * @author Su Liang
|
|
// * @date 2023/03/09
|
|
// *
|
|
// * @copyright © Sicentury Inc.
|
|
// *
|
|
// * @brief
|
|
// *
|
|
// * @details
|
|
// *
|
|
// *
|
|
// * *****************************************************************************/
|
|
|
|
using System;
|
|
using System.Security.Cryptography;
|
|
using System.Text;
|
|
using System.Windows;
|
|
using MECF.Framework.Common.OperationCenter;
|
|
using MECF.Framework.Common.Utilities;
|
|
|
|
namespace MECF.Framework.UI.Client.Ctrlib.Controls
|
|
{
|
|
public partial class PanelLockerPasswordChanger : Window
|
|
{
|
|
public PanelLockerPasswordChanger()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void btnOk_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
#region Validation
|
|
|
|
if (txtOldPass.Password == "")
|
|
{
|
|
txtInfo.Text = "Invalid Old Password";
|
|
txtOldPass.Focus();
|
|
return;
|
|
}
|
|
|
|
if (txtNewPass.Password == "")
|
|
{
|
|
txtInfo.Text = "Invalid New Password";
|
|
txtNewPass.Focus();
|
|
return;
|
|
}
|
|
|
|
if (txtNewPass.Password != txtConfirmPass.Password)
|
|
{
|
|
txtInfo.Text = "New password does not equal to Confirm Password";
|
|
txtNewPass.Focus();
|
|
return;
|
|
}
|
|
|
|
if (txtNewPass.Password == txtOldPass.Password)
|
|
{
|
|
txtInfo.Text = "New password can not be equal to old password";
|
|
txtOldPass.Focus();
|
|
return;
|
|
}
|
|
|
|
#endregion
|
|
|
|
// 获取密码密文
|
|
var oldPassHash = Sha256.EncodeString(txtOldPass.Password);
|
|
var newPassHash = Sha256.EncodeString(txtNewPass.Password);
|
|
|
|
// 发送到RT进行保存
|
|
InvokeClient.Instance.Service.DoOperation("System.SetNewRecipeEditorPassword", oldPassHash, newPassHash);
|
|
DialogResult = true;
|
|
}
|
|
|
|
|
|
private void btnCancel_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
DialogResult = false;
|
|
}
|
|
}
|
|
} |