private void btnResetPassword_ServerClick(object sender, System.EventArgs e) { if (Page.IsValid) { try { // user has filled in all fields, let's reset the password. string mailTemplate = ApplicationAdapter.GetEmailTemplate(EmailTemplate.RegistrationReply); bool result = UserManager.ResetPassword(tbxNickName.Value, tbxEmailAddress.Value, mailTemplate, ApplicationAdapter.GetEmailData()); if (result) { // ok Response.Redirect("ResetPasswordSuccessful.aspx", true); } // not ok lblErrorMessage.Text = "Something went wrong with the reset action. Please try again."; } catch (NickNameNotFoundException ex) { lblErrorMessage.Text = ex.Message; } catch (EmailAddressDoesntMatchException ex) { lblErrorMessage.Text = ex.Message; } // bubble up others. } }
protected void PostMessageHandler(object sender, System.EventArgs e) { string mailTemplate = ApplicationAdapter.GetEmailTemplate(EmailTemplate.ThreadUpdatedNotification); // store the new message in the given thread and close it directly. int messageID = ThreadManager.CreateNewMessageInThreadAndCloseThread(_thread.ThreadID, SessionAdapter.GetUserID(), meMessageEditor.MessageText, meMessageEditor.MessageTextHTML, Request.UserHostAddress.ToString(), meMessageEditor.MessageTextXML, mailTemplate, ApplicationAdapter.GetEmailData(), CacheManager.GetSystemData().SendReplyNotifications); // all ok, redirect to message list int startAtMessageID = ThreadGuiHelper.GetStartAtMessageForGivenMessageAndThread(_thread.ThreadID, messageID, SessionAdapter.GetUserDefaultNumberOfMessagesPerPage()); Response.Redirect("Messages.aspx?ThreadID=" + _thread.ThreadID + "&StartAtMessage=" + startAtMessageID + "&#" + messageID, true); }
/// <summary> /// Handles the click event on the register button. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnRegister_ServerClick(object sender, System.EventArgs e) { if (Page.IsValid) { string nickName = HttpUtility.HtmlEncode(tbxNickName.Value); // check if the nickname is already taken. bool nickNameAlreadyExists = UserGuiHelper.CheckIfNickNameExists(nickName); if (nickNameAlreadyExists) { // already exists lblNickNameError.Visible = true; } else { // doesn't exist. Form is valid, so write the data into the database. DateTime?dateOfBirth = null; string emailAddress = string.Empty; bool emailAddressIsPublic = false; string iconURL = string.Empty; string ipNumber = string.Empty; string location = string.Empty; string occupation = string.Empty; string password = string.Empty; string signature = string.Empty; string website = string.Empty; bool autoSubscribeThreads = true; short defaultMessagesPerPage = 10; if (tbxDateOfBirth.Value.Length > 0) { try { dateOfBirth = System.DateTime.Parse(tbxDateOfBirth.Value, CultureInfo.InvariantCulture.DateTimeFormat); } catch (FormatException) { // format exception, date invalid, ignore, will resolve to the default : null } } emailAddress = tbxEmailAddress.Value; emailAddressIsPublic = !chkEmailAddressIsHidden.Checked; if (tbxIconURL.Value.Length > 0) { iconURL = tbxIconURL.Value; } ipNumber = lblIPNumber.Text; if (tbxLocation.Value.Length > 0) { location = tbxLocation.Value; } if (tbxOccupation.Value.Length > 0) { occupation = tbxOccupation.Value; } if (tbxSignature.Value.Length > 0) { signature = tbxSignature.Value; } if (tbxWebsite.Value.Length > 0) { website = tbxWebsite.Value; } //Preferences autoSubscribeThreads = chkAutoSubscribeToThread.Checked; if (tbxDefaultNumberOfMessagesPerPage.Value.Length > 0) { defaultMessagesPerPage = HnDGeneralUtils.TryConvertToShort(tbxDefaultNumberOfMessagesPerPage.Value); } // add it string mailTemplate = ApplicationAdapter.GetEmailTemplate(EmailTemplate.RegistrationReply); int userID = UserManager.RegisterNewUser(nickName, dateOfBirth, emailAddress, emailAddressIsPublic, iconURL, ipNumber, location, occupation, signature, website, mailTemplate, ApplicationAdapter.GetEmailData(), ApplicationAdapter.GetParserData(), autoSubscribeThreads, defaultMessagesPerPage); Response.Redirect("registrationsuccessful.aspx", true); } } }
protected void PostMessageHandler(object sender, System.EventArgs e) { int userID = SessionAdapter.GetUserID(); // store the new message in the given thread string mailTemplate = ApplicationAdapter.GetEmailTemplate(EmailTemplate.ThreadUpdatedNotification); int messageID = ThreadManager.CreateNewMessageInThread(_thread.ThreadID, userID, meMessageEditor.MessageText, meMessageEditor.MessageTextHTML, Request.UserHostAddress.ToString(), meMessageEditor.MessageTextXML, meMessageEditor.SubscribeToThread, mailTemplate, ApplicationAdapter.GetEmailData(), CacheManager.GetSystemData().SendReplyNotifications); // invalidate forum RSS in cache ApplicationAdapter.InvalidateCachedForumRSS(_thread.ForumID); // if auditing is required, we've to do this now. if (SessionAdapter.CheckIfNeedsAuditing(AuditActions.AuditNewMessage)) { SecurityManager.AuditNewMessage(userID, messageID); } // invalidate forum in asp.net cache CacheManager.InvalidateCachedItem(CacheManager.ProduceCacheKey(CacheKeys.SingleForum, _thread.ForumID)); // all ok, redirect to message list int startAtMessageIndex = ThreadGuiHelper.GetStartAtMessageForGivenMessageAndThread(_thread.ThreadID, messageID, SessionAdapter.GetUserDefaultNumberOfMessagesPerPage()); if (meMessageEditor.AddAttachment) { // redirect to manage attachment form for this message Response.Redirect(string.Format("Attachments.aspx?SourceType=1&MessageID={0}", messageID), true); } else { Response.Redirect(string.Format("Messages.aspx?ThreadID={0}&StartAtMessage={1}&#{2}", _thread.ThreadID, startAtMessageIndex, messageID), true); } }