Added dialog to change the password
This commit is contained in:
parent
2b9c6f445b
commit
c5411570e4
@ -236,6 +236,9 @@
|
|||||||
<Compile Include="Controls\ValueMappingsControl.xaml.cs">
|
<Compile Include="Controls\ValueMappingsControl.xaml.cs">
|
||||||
<DependentUpon>ValueMappingsControl.xaml</DependentUpon>
|
<DependentUpon>ValueMappingsControl.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="EditControls\ChangePasswordDialog.xaml.cs">
|
||||||
|
<DependentUpon>ChangePasswordDialog.xaml</DependentUpon>
|
||||||
|
</Compile>
|
||||||
<Compile Include="EditControls\CompareExcelDialog.xaml.cs">
|
<Compile Include="EditControls\CompareExcelDialog.xaml.cs">
|
||||||
<DependentUpon>CompareExcelDialog.xaml</DependentUpon>
|
<DependentUpon>CompareExcelDialog.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
@ -568,6 +571,10 @@
|
|||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
</Page>
|
</Page>
|
||||||
|
<Page Include="EditControls\ChangePasswordDialog.xaml">
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
</Page>
|
||||||
<Page Include="EditControls\CompareExcelDialog.xaml">
|
<Page Include="EditControls\CompareExcelDialog.xaml">
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
|||||||
33
ENI2/EditControls/ChangePasswordDialog.xaml
Normal file
33
ENI2/EditControls/ChangePasswordDialog.xaml
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
<enictrl:EditWindowBase x:Class="ENI2.EditControls.ChangePasswordDialog"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:enictrl="clr-namespace:ENI2.Controls"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
Title="Change password" Height="215" Width="400" Loaded="EditWindowBase_Loaded" Background="AliceBlue">
|
||||||
|
<Grid>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="28" />
|
||||||
|
<RowDefinition Height="28" />
|
||||||
|
<RowDefinition Height="28" />
|
||||||
|
<RowDefinition Height="28" />
|
||||||
|
<RowDefinition Height="28" />
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width=".4*" />
|
||||||
|
<ColumnDefinition Width=".6*" />
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
|
||||||
|
<Label Grid.Row="0" Grid.Column="0" Content="Name" />
|
||||||
|
<Label Grid.Row="1" Grid.Column="0" Content="Old password" />
|
||||||
|
<Label Grid.Row="2" Grid.Column="0" Content="New password" />
|
||||||
|
<Label Grid.Row="3" Grid.Column="0" Content="Repeat new password" />
|
||||||
|
<TextBlock Grid.Row="0" Grid.Column="1" x:Name="textBlockName" VerticalAlignment="Center" FontWeight="DemiBold"/>
|
||||||
|
<PasswordBox Grid.Row="1" Grid.Column="1" x:Name="textBoxOldPassword" Margin="2" VerticalContentAlignment="Center" />
|
||||||
|
<PasswordBox Grid.Row="2" Grid.Column="1" x:Name="textBoxNew1Password" Margin="2" VerticalContentAlignment="Center" />
|
||||||
|
<PasswordBox Grid.Row="3" Grid.Column="1" x:Name="textBoxNew2Password" Margin="2" VerticalContentAlignment="Center" />
|
||||||
|
<Button Grid.Row="4" Grid.Column="1" Content="Change" Name="buttonChangePassword" Margin="2" Width="80" HorizontalAlignment="Left" Click="buttonChangePassword_Click"/>
|
||||||
|
|
||||||
|
</Grid>
|
||||||
|
</enictrl:EditWindowBase>
|
||||||
90
ENI2/EditControls/ChangePasswordDialog.xaml.cs
Normal file
90
ENI2/EditControls/ChangePasswordDialog.xaml.cs
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
// Copyright (c) 2017- schick Informatik
|
||||||
|
// Description: Users may change their password
|
||||||
|
//
|
||||||
|
|
||||||
|
using bsmd.database;
|
||||||
|
using ENI2.Controls;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
|
||||||
|
namespace ENI2.EditControls
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Interaction logic for ChangePasswordDialog.xaml
|
||||||
|
/// </summary>
|
||||||
|
public partial class ChangePasswordDialog : EditWindowBase
|
||||||
|
{
|
||||||
|
|
||||||
|
#region Construction
|
||||||
|
|
||||||
|
public ChangePasswordDialog()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Properties
|
||||||
|
|
||||||
|
public ReportingParty CurrentUser { get; set; }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region event handler
|
||||||
|
|
||||||
|
private void buttonChangePassword_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
bool success = false;
|
||||||
|
string message = "";
|
||||||
|
if(!textBoxOldPassword.Password.IsNullOrEmpty())
|
||||||
|
{
|
||||||
|
if(CurrentUser.GetHash(textBoxOldPassword.Password).Equals(CurrentUser.PasswordHash))
|
||||||
|
{
|
||||||
|
if(textBoxNew1Password.Password.IsNullOrEmpty() ||
|
||||||
|
textBoxNew2Password.Password.IsNullOrEmpty() ||
|
||||||
|
!textBoxNew1Password.Password.Equals(textBoxNew2Password.Password))
|
||||||
|
{
|
||||||
|
message = "New passwords are empty or do not match";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (textBoxOldPassword.Password.Equals(textBoxNew1Password.Password))
|
||||||
|
{
|
||||||
|
message = "Old and new password are the same";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CurrentUser.SetPassword(textBoxNew1Password.Password);
|
||||||
|
DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).Save(CurrentUser);
|
||||||
|
success = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
message = "Old password is not correct";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
message = "Old password empty";
|
||||||
|
}
|
||||||
|
if (!success)
|
||||||
|
MessageBox.Show(message, "Changing password failed", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||||
|
else
|
||||||
|
MessageBox.Show("Password successfully changed.", "Password changed", MessageBoxButton.OK, MessageBoxImage.Information);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void EditWindowBase_Loaded(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
this.textBlockName.Text = CurrentUser.Name;
|
||||||
|
this.AddVisible = false;
|
||||||
|
this.OkVisible = false;
|
||||||
|
var cancelButton = (Button)Template.FindName("buttonCancel", this);
|
||||||
|
cancelButton.Content = "Close";
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -97,6 +97,11 @@
|
|||||||
<MenuItem x:Name="menuItemValueMappings" Header="{x:Static p:Resources.textExcelValueMappings}" Click="radioButton_Click" Visibility="Hidden" />
|
<MenuItem x:Name="menuItemValueMappings" Header="{x:Static p:Resources.textExcelValueMappings}" Click="radioButton_Click" Visibility="Hidden" />
|
||||||
<MenuItem x:Name="labelStatusId" />
|
<MenuItem x:Name="labelStatusId" />
|
||||||
<MenuItem Header="Help" HorizontalAlignment="Right">
|
<MenuItem Header="Help" HorizontalAlignment="Right">
|
||||||
|
<MenuItem Header="Change Password" Click="buttonChangePassword_Click">
|
||||||
|
<MenuItem.Icon>
|
||||||
|
<Image Source="Resources/lock.png" />
|
||||||
|
</MenuItem.Icon>
|
||||||
|
</MenuItem>
|
||||||
<MenuItem Header="About" Click="buttonAbout_Click">
|
<MenuItem Header="About" Click="buttonAbout_Click">
|
||||||
<MenuItem.Icon>
|
<MenuItem.Icon>
|
||||||
<Image Source="Resources/about.png" />
|
<Image Source="Resources/about.png" />
|
||||||
|
|||||||
@ -328,7 +328,13 @@ namespace ENI2
|
|||||||
{
|
{
|
||||||
compareExcelDialog.BringUp();
|
compareExcelDialog.BringUp();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonChangePassword_Click(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
ChangePasswordDialog cpd = new ChangePasswordDialog();
|
||||||
|
cpd.CurrentUser = this.userEntity;
|
||||||
|
cpd.ShowDialog();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@ -735,6 +741,6 @@ namespace ENI2
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,5 +3,5 @@
|
|||||||
[assembly: AssemblyCompany("schick Informatik")]
|
[assembly: AssemblyCompany("schick Informatik")]
|
||||||
[assembly: AssemblyProduct("BSMD NSW interface")]
|
[assembly: AssemblyProduct("BSMD NSW interface")]
|
||||||
[assembly: AssemblyInformationalVersion("7.2.2")]
|
[assembly: AssemblyInformationalVersion("7.2.2")]
|
||||||
[assembly: AssemblyCopyright("Copyright © 2014-2023 schick Informatik")]
|
[assembly: AssemblyCopyright("Copyright © 2014-2024 schick Informatik")]
|
||||||
[assembly: AssemblyTrademark("")]
|
[assembly: AssemblyTrademark("")]
|
||||||
Loading…
Reference in New Issue
Block a user