Move change password logic to person
This commit is contained in:
parent
ed6c37194c
commit
16c009b432
@ -98,6 +98,45 @@ namespace EduNetworkBuilder
|
|||||||
Password = NewPassword;
|
Password = NewPassword;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void ChangePassword(bool TryOnce=false)
|
||||||
|
{
|
||||||
|
bool done = false;
|
||||||
|
while (!done)
|
||||||
|
{
|
||||||
|
if (TryOnce) done = true; //Just attempt it once.
|
||||||
|
string OldPassword = "";
|
||||||
|
if (Password != "")
|
||||||
|
{
|
||||||
|
OldPassword = NB.TextPromptBox(NB.Translate("PPF_OldPassword"), Properties.Resources.NBIco, true);
|
||||||
|
if (OldPassword != Password)
|
||||||
|
{
|
||||||
|
MessageBox.Show(NB.Translate("PPF_PassMismatch"));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//The passwords match, or there was no initial password.
|
||||||
|
string Password1 = NB.TextPromptBox(NB.Translate("PPF_NewPass"), Properties.Resources.NBIco, true);
|
||||||
|
if (Password1.Length < 4)
|
||||||
|
{
|
||||||
|
MessageBox.Show(NB.Translate("PPF_PassTooShort"));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (Password1 == OldPassword)
|
||||||
|
{
|
||||||
|
MessageBox.Show(NB.Translate("PPF_PassDidNotChange"));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
string Password2 = NB.TextPromptBox(NB.Translate("PPF_VerifyPass"), Properties.Resources.NBIco, true);
|
||||||
|
if (Password1 != Password2)
|
||||||
|
{
|
||||||
|
MessageBox.Show(NB.Translate("PPF_PassValidateMismatch"));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
ChangePassword(Password1);
|
||||||
|
done = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#region Load and Save
|
#region Load and Save
|
||||||
//Load and save functions
|
//Load and save functions
|
||||||
public bool Load(string filename, string password = "")
|
public bool Load(string filename, string password = "")
|
||||||
|
@ -342,36 +342,7 @@ namespace EduNetworkBuilder
|
|||||||
|
|
||||||
private void btnChangePassword_Click(object sender, EventArgs e)
|
private void btnChangePassword_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
string OldPassword = "";
|
CurrentUser.ChangePassword(true); //Try to change it once.
|
||||||
if (CurrentUser.Password != "")
|
|
||||||
{
|
|
||||||
OldPassword = NB.TextPromptBox(NB.Translate("PPF_OldPassword"), Properties.Resources.NBIco, true);
|
|
||||||
if(OldPassword != CurrentUser.Password)
|
|
||||||
{
|
|
||||||
MessageBox.Show(NB.Translate("PPF_PassMismatch"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//The passwords match, or there was no initial password.
|
|
||||||
string Password1 = NB.TextPromptBox(NB.Translate("PPF_NewPass"), Properties.Resources.NBIco, true);
|
|
||||||
if(Password1.Length < 4)
|
|
||||||
{
|
|
||||||
MessageBox.Show(NB.Translate("PPF_PassTooShort"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(Password1 == OldPassword)
|
|
||||||
{
|
|
||||||
MessageBox.Show(NB.Translate("PPF_PassDidNotChange"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
string Password2 = NB.TextPromptBox(NB.Translate("PPF_VerifyPass"), Properties.Resources.NBIco, true);
|
|
||||||
if(Password1 != Password2)
|
|
||||||
{
|
|
||||||
MessageBox.Show(NB.Translate("PPF_PassValidateMismatch"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
CurrentUser.ChangePassword(Password1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Font GetFont()
|
public Font GetFont()
|
||||||
|
Loading…
Reference in New Issue
Block a user