protected void Page_Load(object sender, EventArgs e) { if (!Organization.setCurrent()) { Response.Redirect(LiftContext.Redirect); } PageAuthorized.check(Request, Response); Organization org = Organization.Current; if (org != null) { customPath = "/custom/"; customPath += org.subdomain; } try { string search = string.Empty; UserState state = UserState.unknown; searchBtn.Text = LiftDomain.Language.Current.SHARED_SEARCH; LiftDomain.User thisUserList = new LiftDomain.User(); if (IsPostBack) { search = liveSearchBox.Text; state = (UserState)Convert.ToInt32(user_status_list.SelectedValue); if (search.Length == 0) { search = "%"; } } else { if (Session["last_user_list_search"] != null) { search = Session["last_user_list_search"].ToString(); } else { search = string.Empty; } if (Session["last_user_list_state"] != null) { state = (UserState)Convert.ToInt32(Session["last_user_list_state"]); } else { state = UserState.unknown; } } initUserStatusList(state); //------------------------------------------------------------------------- //-- !!!KLUDGE ALERT: if first time on this page -or- search string is blank, //-- !!!KLUDGE ALERT: then use a dummy search value which will return no records //------------------------------------------------------------------------- if (String.IsNullOrEmpty(search)) { search = "%"; } Session["last_user_list_search"] = search; Session["last_user_list_state"] = (int)state; string searchAction = "SearchUsersByFirstOrLast"; thisUserList["search"] = search; thisUserList["state"] = (int)state; if (LiftDomain.User.Current.IsInRole(Role.SYS_ADMIN)) { thisUserList.OverrideAutoOrgAssignment = true; searchAction = "SearchUsersByFirstOrLastSysAdmin"; } userListSet = thisUserList.doQuery(searchAction); if (userListSet.Tables[0].Rows.Count > 0) { userListSearchResultsLabel.Visible = false; userListTablePanel.Visible = true; userListRenderer = // new PartialRenderer(HttpContext.Current, userListSet, "_UserList.htm", newPartialRenderer.RenderHelper(thisUserList.user_list_helper)); userListRenderer = new UserRenderer(userListSet); } else { if (IsPostBack) { userListSearchResultsLabel.Text = LiftDomain.Language.Current.USER_LIST_NO_MATCHING_RECORDS + "."; } else { userListSearchResultsLabel.Text = LiftDomain.Language.Current.USER_LIST_ENTER_VALUE_TO_MATCH + "."; } userListSearchResultsLabel.Visible = true; userListTablePanel.Visible = false; } } catch (Exception x) { //TODO: ??? WHAT DO WE DO IF THERE IS AN ERROR ??? string m = x.Message; System.Diagnostics.Debug.Print("[" + DateTime.Now.ToString() + "] *** ERROR IN UserList.aspx.cs::Page_Load(): " + m); Logger.log("UserList.aspx.cs", x, "[" + DateTime.Now.ToString() + "] *** ERROR IN UserList.aspx.cs::Page_Load(): " + m); } finally { } }
protected void Page_Load(object sender, EventArgs e) { if (!Organization.setCurrent()) { Response.Redirect(LiftContext.Redirect); } //------------------------------------------------------------------------- //-- do the language setting for the SUBMIT button here //-- (unable to place <%=LiftDomain.Language.Current.SHARED_SUBMIT %> in asp:Button Text field) //------------------------------------------------------------------------- this.submitBtn.Text = LiftDomain.Language.Current.SHARED_SUBMIT; if (IsPostBack) { try { //TODO: ??? HOW DO WE VALIDATE THE FORM FIELD DATA (required, max length, valid e-mail address, dangerous content?, etc.) //------------------------------------------------------------------------- //-- get the information entered on the web form //-- and send it in an e-mail to the organization point of contact //------------------------------------------------------------------------- //-- (org_email and org_appearance will specify recipients and smtp settings) //------------------------------------------------------------------------- //YOUR NAME: = contact_from.Text; //YOUR EMAIL: = contact_from_email.Text; //SUBJECT: = contact_subject.Text; //MESSAGE: = contact_message.Text; Organization currentOrganization = Organization.Current; LiftCommon.Email emailHelper = new LiftCommon.Email(); //email.replyTo = thisOrgEmail.emailReplyTo; // not supported yet emailHelper.from = "*****@*****.**"; //------------------------------------------------------------------------- //-- get list of all users for the current organization //------------------------------------------------------------------------- LiftDomain.User thisUserList = new LiftDomain.User(); thisUserList["search"] = currentOrganization.id.Value; DataSet userListSet = thisUserList.doQuery("SearchUsersByOrg"); foreach (DataRow dr in userListSet.Tables[0].Rows) { string email = dr["email"].ToString(); if (!String.IsNullOrEmpty(email)) { //TODO: ??? VALIDATE THAT THE EMAIL ADDRESS IS A VALID EMAIL ADDRESS FORMAT ??? emailHelper.addTo(email); } } emailHelper.subject = email_subject.Text; // field from the form emailHelper.Body = email_message.Text; // field from the form //email.MIME = MIME.Text | MIME.HTML; // just supposing that it supports multiple formats. May not be necessary emailHelper.send(); //TODO: ??? WHERE DO WE REDIRECT TO ??? //Response.Redirect("Requests.aspx"); } catch (Exception x) { //TODO: ??? WHAT DO WE DO IF THE E-MAIL PROCESS FAILS string m = x.Message; System.Diagnostics.Debug.Print("[" + DateTime.Now.ToString() + "] *** ERROR SENDING E-MAIL: " + m); } finally { } } }
protected void Page_Load(object sender, EventArgs e) { string randomPassword = string.Empty; string saltValue = string.Empty; int ok = 0; string targetEmail = string.Empty; EmailValidator.ErrorMessage = LiftDomain.Language.Current.SHARED_MUST_BE_A_VALID_EMAIL_ADDRESS; if (!Organization.setCurrent()) { Response.Redirect(LiftContext.Redirect); } try { //------------------------------------------------------------------------- //-- do the language setting for the SUBMIT button here //-- (unable to place <%=LiftDomain.Language.Current.SHARED_SUBMIT %> in asp:Button Text field) //------------------------------------------------------------------------- this.submitBtn.Text = LiftDomain.Language.Current.SHARED_SUBMIT.Value; string email = Request["email"]; if (!string.IsNullOrEmpty(email)) { user_email.Text = email; } //------------------------------------------------------------------------- //-- do other language settings //------------------------------------------------------------------------- forgot_password_fieldset_legend = LiftDomain.Language.Current.FORGOT_PASSWORD_INSTRUCTIONS.Value; if (IsPostBack) { //TODO: ???what if CAPTCHA validation fails??? //TODO: ???should we be doing validation checking in Page_Load or submitBtn_Click??? //if (Page.IsValid && (txtCaptcha.Text.ToString() == Session["captchaValue"].ToString())) if (txtCaptcha.Text.ToString().Trim().ToUpper() == Session["captchaValue"].ToString().Trim().ToUpper()) { //Response.Write("CAPTCHA verification succeeded"); //------------------------------------------------------------------------- //-- validate given e-mail (required, valid e-mail) //------------------------------------------------------------------------- //------------------------------------------------------------------------- //-- determine if user exists for given e-mail //------------------------------------------------------------------------- LiftDomain.User thisUserList = new LiftDomain.User(); thisUserList["search"] = user_email.Text; userListSet = thisUserList.doQuery("SearchUsersByEmail"); //TODO: ???what if multiple user records are found for the given email address??? if (userListSet.Tables[0].Rows.Count > 0) { LiftDomain.User thisUser = new LiftDomain.User(); thisUser.id.Value = Convert.ToInt32(userListSet.Tables[0].Rows[0]["id"]); string username = userListSet.Tables[0].Rows[0]["username"].ToString(); //------------------------------------------------------------------------- //-- create new random password for user //------------------------------------------------------------------------- randomPassword = LiftDomain.User.generatePassword(); //------------------------------------------------------------------------- //-- update user record with new password //------------------------------------------------------------------------- thisUser.password_hash_type.Value = "md5"; saltValue = LiftDomain.User.generateRandomSalt(); thisUser.password_salt.Value = saltValue; thisUser.crypted_password.Value = LiftDomain.User.hash(randomPassword, saltValue); thisUser.last_password_changed_date.Value = LiftTime.CurrentTime; thisUser.updated_at.Value = LiftTime.CurrentTime; thisUser.id.Value = Convert.ToInt32(thisUser.doCommand("save")); //------------------------------------------------------------------------- //-- send new randomly-generated password to the given e-mail address //------------------------------------------------------------------------- LiftCommon.Email emailHelper = new LiftCommon.Email(); //email.replyTo = thisOrgEmail.emailReplyTo; // not supported yet emailHelper.from = Organization.Current.getFromEmail(); if (LiftCommon.Email.IsValidEmailAddress(user_email.Text)) { targetEmail = user_email.Text; try { StringBuilder body = new StringBuilder(); emailHelper.addTo(targetEmail); emailHelper.subject = LiftDomain.Language.Current.FORGOT_PASSWORD_NOTIFICATION_SUBJECT.Value; body.Append(LiftDomain.Language.Current.FORGOT_PASSWORD_NOTIFICATION_MESSAGE.Value); body.Append("\r\n"); body.Append(LiftDomain.Language.Current.USER_EMAIL); body.Append("\t"); body.Append(targetEmail); body.Append("\r\n"); body.Append(LiftDomain.Language.Current.LOGIN_THE_NEW_PASSWORD); body.Append("\t"); body.Append(randomPassword); body.Append("\r\n"); emailHelper.Body = body.ToString(); //email.MIME = MIME.Text | MIME.HTML; // just supposing that it supports multiple formats. May not be necessary emailHelper.send(); ok = 1; } catch { ok = 0; } } } } //------------------------------------------------------------------------- //-- redirect to the "password has been reset, you should receive an e-mail" page //------------------------------------------------------------------------- Response.Redirect("PasswordReset.aspx?ok=" + ok.ToString() + "&e=" + targetEmail); } else { //------------------------------------------------------------------------- //-- first time on this page, so ...??? //------------------------------------------------------------------------- } } catch (Exception x) { //TODO: ??? WHAT DO WE DO IF THERE IS AN ERROR ??? string m = x.Message; System.Diagnostics.Debug.Print("[" + DateTime.Now.ToString() + "] *** ERROR IN ForgotPassword.aspx.cs::Page_Load(): " + m); Logger.log("ForgotPassword.aspx.cs", x, "[" + DateTime.Now.ToString() + "] *** ERROR IN ForgotPassword.aspx.cs::Page_Load(): " + m); //Response.Write(m); } finally { } }