private void butOK_Click(object sender, System.EventArgs e) { Userod selectedUser = (Userod)listUser.SelectedItem; if (!Userods.CheckTypedPassword(textPassword.Text, selectedUser.Password)) { MsgBox.Show(this, "Incorrect password"); return; } if (RemotingClient.RemotingRole == RemotingRole.ClientWeb && selectedUser.Password == "" && textPassword.Text == "") { MsgBox.Show(this, "When using the web service, not allowed to log in with no password. A password should be added for this user."); return; } Security.CurUser = selectedUser.Copy(); if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { string password = textPassword.Text; if (Programs.UsingEcwTight()) //ecw requires hash, but non-ecw requires actual password { password = Userods.EncryptPassword(password, true); } Security.PasswordTyped = password; } if (PrefC.GetBool(PrefName.TasksCheckOnStartup)) { int taskcount = Tasks.UserTasksCount(Security.CurUser.UserNum); if (taskcount > 0) { MessageBox.Show(Lan.g(this, "There are ") + taskcount + Lan.g(this, " unread tasks on your tasklists.")); } } Plugins.HookAddCode(this, "FormLogOn.butOK_Click_end"); DialogResult = DialogResult.OK; }
///<summary>Returns true if the From provider is associated to the user currently logged in. ///If the user has chosen a different provider as the From provider this will prompt them to enter a password for any user associated to them. ///Loops through all users associated to the From provider until the credentials typed in match.</summary> private bool VerifyFromProvider() { if (_provCur == null) { MsgBox.Show(this, "Invalid From provider."); return(false); } //Don't require validating credentials if the user currently logged in is associated to the selected provider. if (_provUserCur != null && _provUserCur.ProvNum == _provCur.ProvNum) { return(true); } List <Userod> listUsers = Userods.GetUsersByProvNum(_provCur.ProvNum); //Get all potential users for this provider. InputBox FormIB = new InputBox(Lan.g(this, "Input a password for a User that is associated to provider:") + "\r\n" + _provCur.GetFormalName()); FormIB.textResult.PasswordChar = '*'; while (true) { //Get the password for a user that is associated to the provider chosen. FormIB.textResult.Text = ""; FormIB.ShowDialog(); if (FormIB.DialogResult == DialogResult.OK) { //Validate the password typed in against all the users associated to the selected provider. foreach (Userod user in listUsers) { if (Userods.CheckTypedPassword(FormIB.textResult.Text, user.Password)) { return(true); } } MsgBox.Show(this, "Invalid password. Please try again or Cancel."); } else //User canceled { return(false); } } }
///<summary>Will ask for password if the current user logged in isn't the user status being manipulated.</summary> private static bool CheckSelectedUserPassword(long employeeNum) { if (Security.CurUser.EmployeeNum == employeeNum) { return(true); } Userod selectedUser = Userods.GetUserByEmployeeNum(employeeNum); InputBox inputPass = new InputBox("Please enter password:"******"PhoneUI", "Wrong password."); return(false); } return(true); }