private void SendEmailConfirmation() { using (cec_publicservice.CECInputFormService websrv = new CECInputFormService()) { UserData ud = websrv.GetUserInformationByUserID(UserToken, UserToken.userid); System.Collections.Specialized.NameValueCollection data = new NameValueCollection(); data.Add("name", ud.display_name); data.Add("to", ud.email); websrv.CreateEmailAndSend(UserToken, "user_info_update", data); } }
protected void submitBtnClicked(object sender, EventArgs e) { string validationErrors = string.Empty; if (!ValidateFields(out validationErrors)) { rg_errorMsg.InnerHtml = String.Format("Please complete the missing fields. <p>{0}</p>", validationErrors); rg_errorMsg.Attributes["role"] = "alert"; string script = "<script type=\"text/javascript\"> $(function() { $('#contactOverlay').modal('show'); }); </script>"; Page.ClientScript.RegisterStartupScript(this.GetType(), "contact_validation_errors", script); //RegisterJSAlert(rg_errorMsg.InnerText); return; } try { using (cec_publicservice.CECInputFormService websrv = new CECInputFormService()) { System.Collections.Specialized.NameValueCollection data = new NameValueCollection(); data.Add("first_name", cu_firstName.Text); data.Add("last_name", cu_lastName.Text); data.Add("institution_affiliation", cu_organization.Text); data.Add("phone_number", cu_phone.Text); data.Add("email_address", cu_email.Text); data.Add("topic", cu_topic.SelectedItem.Text); data.Add("email", cu_email.Text); websrv.CreateEmailAndSend(helper.CreateTemporaryToken(), "helpdesk_inbound", data); data.Clear(); data.Add("to", cu_email.Text); websrv.CreateEmailAndSend(helper.CreateTemporaryToken(), "helpdesk_outbound", data); } } catch (Exception ex) { rg_errorMsg.InnerText = "Failed to send email"; #if (DEBUG || DEBUGDEV) rg_errorMsg.InnerText += String.Format(" ({0})", ex.Message); #endif //LogError(rg_errorMsg.InnerText, ex); } }
private void loginBtnClick(object sender, EventArgs e) { SecurityToken token = new SecurityToken(); CECMembershipProvider prov = (Membership.Providers["CECProvider"] as CECMembershipProvider); try { string validation_errors = string.Empty; if (String.IsNullOrWhiteSpace(usernameIn.Value)) { validation_errors += "<p>Username cannot be blank</p>"; } if (String.IsNullOrWhiteSpace(passwordIn.Value)) { validation_errors += "<p>Password cannot be blank</p>"; } if (!String.IsNullOrEmpty(validation_errors)) { throw new Exception(validation_errors); } if (prov.ValidateUser(usernameIn.Value, passwordIn.Value, out token)) { string local_userfiles_path = MapPath(String.Format("/user_files/{0}", token.userid)); if (!Directory.Exists(local_userfiles_path)) { Directory.CreateDirectory(local_userfiles_path); } using (cec_publicservice.CECInputFormService websrv = new CECInputFormService()) { // verify/handle user account conditions UserData ud = websrv.GetUserInformationByUserID(token, token.userid); using (cec_publicservice.CECHarmPublicService pubsrv = new CECHarmPublicService()) { if (ud.account_lockout) { pubsrv.AuditLog_AddActivity(ud.userid, "login attempted; failed due to lockout"); throw new AccountLockedOutException(ud.email, ud.account_lockout_date); } // user was successfully authenticated, so set the auth cookie FormsAuthentication.SetAuthCookie(token.email, false); Session["UserSecurityToken"] = token; Response.SetCookie(new HttpCookie("sessionid", token.session)); Response.SetCookie(new HttpCookie("uid", token.userid.ToString())); Response.SetCookie(new HttpCookie("edit_mode", "")); pubsrv.AuditLog_AddActivity(ud.userid, "login"); } if (ud.password_reset_required || ud.password_expired) { Page.Response.Redirect("/userinfo.aspx?resetPassword", false); } else { Page.Response.Redirect("/input/bouncer.aspx", false); } //FormsAuthentication.RedirectFromLoginPage(token.email, false); } } else { throw new Exception("Unknown login failure"); } } catch (Exception ex) { string script = "<script type=\"text/javascript\"> $(function() { $('#invalidlogin_msg').html('" + ex.Message + "').show(); $('#login_dialog').modal('show'); }); </script>"; Page.ClientScript.RegisterStartupScript(this.GetType(), "login_errors", script); } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); string proxy_location = (Request.Url.Host == "localhost" ? "{0}://{1}/cec_service/cec_inputform.ashx?proxy" : "{0}://{1}/input/cec_inputform.ashx?proxy"); Page.ClientScript.RegisterClientScriptInclude("webproxy", String.Format(proxy_location, Request.Url.Scheme, Request.Url.Host)); bool isLoggedIn = false; if (Request.Cookies[FormsAuthentication.FormsCookieName] != null) { HttpCookie authCookie = Request.Cookies[FormsAuthentication.FormsCookieName]; if (!helper.IsStringEmptyWhiteSpace(authCookie.Value)) { FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(authCookie.Value); if (!ticket.Expired && (Request.Cookies["uid"] != null && Request.Cookies["uid"].Value != "")) { isLoggedIn = true; } } } if (isLoggedIn) { if (UserToken.TokenSet) { userToken.Value = new JavaScriptSerializer().Serialize(UserToken); } using (cec_publicservice.CECInputFormService websrv = new CECInputFormService()) { if (!websrv.ValidateSecurityToken(UserToken)) { return; } liLogin.Controls.Clear(); UserData usrData = websrv.GetUserInformationByUserID(UserToken, int.Parse(Request.Cookies["uid"].Value)); System.Web.UI.HtmlControls.HtmlAnchor usrLink = new HtmlAnchor(); usrLink.ID = "user_profile"; usrLink.HRef = "/userinfo.aspx"; usrLink.InnerHtml = String.Format("{0} —Account", usrData.display_name); liLogin.Controls.Add(usrLink); System.Web.UI.HtmlControls.HtmlAnchor logoutLink = new HtmlAnchor(); logoutLink.Attributes["onclick"] = "logOut();"; logoutLink.ID = "user_logout"; logoutLink.InnerText = "Logout"; liLogin.Controls.Add(logoutLink); } } else { //set li active if (Page.AppRelativeVirtualPath.Contains("cohortselect")) { liSelect.Attributes["class"] += " active"; } else if (Page.AppRelativeVirtualPath.Contains("select")) { liHome.Attributes["class"] += " active"; } else if (Page.AppRelativeVirtualPath.Contains("about")) { liAbout.Attributes["class"] += " active"; } else if (Page.AppRelativeVirtualPath.Contains("biospecimen")) { liBiospecimen.Attributes["class"] += " active"; } else if (Page.AppRelativeVirtualPath.Contains("cancer")) { liCancer.Attributes["class"] += " active"; } else if (Page.AppRelativeVirtualPath.Contains("enrollment")) { liEnrollment.Attributes["class"] += " active"; } loginBtn.Click += new EventHandler(loginBtnClick); } // do logout if (Request.QueryString.ToString().Contains("logout")) { Session.RemoveAll(); FormsAuthentication.SignOut(); } }
protected override void OnLoad(EventArgs e) { foreach (string k in Attributes.Keys) { (Controls[0] as HtmlContainerControl).Attributes.Add(k, Attributes[k]); } (Controls[0] as HtmlContainerControl).ID = this.ID; int section_id = 1; if (Request.QueryString["section"] != null) { section_id = int.Parse(Request.QueryString["section"]); } string linkQueryStr = ""; if (Request.QueryString.Count > 0) { foreach (string s in Request.QueryString) { if (s.Contains("section")) { continue; } linkQueryStr = String.Format("{0}={1}&", s, Request.QueryString[s]); } } using (cec_publicservice.CECInputFormService ps = new CECInputFormService()) { dt_input = ps.GetInputFields(UserToken); string cohort_record_status = dt_cohort.Rows[0]["status"].ToString().ToLower(); if (cohort_record_status == "published" || cohort_record_status == "unpublished") { published_intro.Visible = true; } else if (cohort_record_status == "pending" && UserToken.access_level == 100) { pending_intro.Visible = true; } else if (cohort_record_status == "pending" && UserToken.access_level >= 200) { reviewer_intro.Visible = true; string list_of_changes = String.Empty; if (!String.IsNullOrWhiteSpace(data_field_changes)) { foreach (string df in data_field_changes.Split(',')) { string field = df; if (field.EndsWith("_no") || field.EndsWith("_yes")) { field = field.Remove(df.LastIndexOf('_'), (field.Length - field.LastIndexOf('_'))); } if (dt_input.Select(String.Format("data_field='{0}'", field)).Length == 0) { continue; } DataRow dr_input = dt_input.Select(String.Format("data_field='{0}'", field))[0]; string url = string.Empty; if ((int)dr_input["section"] != section_id) { url = String.Format("/input/edit.aspx?{0}section={1}#{2}", linkQueryStr, dr_input["section"], df); } else { url = String.Format("#{0}", df); } string change_label = String.Format("<span class=\"change-label\">{0}</span> <a class=\"change-link\" href=\"{1}\">Go to</a>", helper.StripHTML(ps.GetInputFieldQuestionText(UserToken, field)), url); list_of_changes += String.Format("<li>{0}</li>", change_label); } change_count.InnerText = data_field_changes.Split(',').Length.ToString(); list_changes.InnerHtml = String.Format("<ul>{0}</ul>", list_of_changes); } else { change_count.InnerText = "0"; list_changes.InnerHtml = "<u>Nothing has changed.</u>"; } } else { draft_intro.Visible = true; } } }