Get encryption / decryption working for users.
This commit is contained in:
parent
1e598470ef
commit
e6518e3918
@ -1743,7 +1743,24 @@ namespace EduNetworkBuilder
|
||||
}
|
||||
else if (extension == ".enbu")
|
||||
{
|
||||
CurrentUser = new PersonClass(filename);
|
||||
int counter = 0;
|
||||
PersonClass tUser = null;
|
||||
while (counter < 3)
|
||||
{
|
||||
string tPass = NB.TextPromptBox("Enter a password", Properties.Resources.NBIco, true);
|
||||
string tUserName = Path.GetFileNameWithoutExtension(filename);
|
||||
string PasToUse = tUserName + tPass;
|
||||
tUser = PersonClass.TryLoad(filename, PasToUse);
|
||||
if (tUser != null) break;
|
||||
counter++;
|
||||
}
|
||||
if(tUser == null)
|
||||
{
|
||||
//failed to load.
|
||||
MessageBox.Show("Too many password failures. Exiting.");
|
||||
return;
|
||||
}
|
||||
CurrentUser = tUser;
|
||||
CurrentUser.filepath = Path.GetDirectoryName(filename); //store the directory
|
||||
OurSettings = NB.GetSettings(); //Grab the new settings from the user
|
||||
UpdateMenu();
|
||||
|
@ -44,9 +44,8 @@ namespace EduNetworkBuilder
|
||||
/// Used to determine if the user we are working with is the admin account.
|
||||
/// </summary>
|
||||
public bool isAdmin { get; protected set; }
|
||||
/// <summary>
|
||||
/// EverCompletedPuzzles is a list of puzzles that they have completed once.
|
||||
/// </summary>
|
||||
|
||||
public string EncryptionPassword { get { return UserName + Password; } }
|
||||
|
||||
public List<SchoolworkClass> Projects = new List<SchoolworkClass>();
|
||||
|
||||
@ -79,7 +78,20 @@ namespace EduNetworkBuilder
|
||||
{
|
||||
Load(reader);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Try to load the specified filename. Return a new person record if it succeeds.
|
||||
/// Return null if it fails to load. (bad password, bad file, etc)
|
||||
/// </summary>
|
||||
/// <param name="Filename">The filename to load</param>
|
||||
/// <param name="password">The password to try</param>
|
||||
/// <returns></returns>
|
||||
public static PersonClass TryLoad(string Filename, string password)
|
||||
{
|
||||
PersonClass pc = new PersonClass();
|
||||
if (pc.Load(Filename, password))
|
||||
return pc;
|
||||
return null;
|
||||
}
|
||||
|
||||
public void ChangePassword(string NewPassword)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user