private void btnLogin_ServerClick(object sender, System.EventArgs e) { // try to authenticate the user UserEntity user = null; SecurityManager.AuthenticateResult result = SecurityManager.AuthenticateUser(tbxUserName.Value, tbxPassword.Value, out user); switch (result) { case SecurityManager.AuthenticateResult.AllOk: // authenticated // Save session cacheable data SessionAdapter.LoadUserSessionData(user); // update last visit date in db UserManager.UpdateLastVisitDateForUser(user.UserID); // done FormsAuthentication.RedirectFromLoginPage(tbxUserName.Value, chkPersistentLogin.Checked); // Audit the login action, if it was defined to be logged for this role. if (SessionAdapter.CheckIfNeedsAuditing(AuditActions.AuditLogin)) { SecurityManager.AuditLogin(SessionAdapter.GetUserID()); } break; case SecurityManager.AuthenticateResult.IsBanned: lblErrorMessage.Text = "You are banned. Login won't work for you."; break; case SecurityManager.AuthenticateResult.WrongUsernamePassword: lblErrorMessage.Text = "You specified a wrong User name - Password combination. Try again."; break; } }
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); } }
protected void PostMessageHandler(object sender, System.EventArgs e) { ThreadManager.UpdateMemo(_thread.ThreadID, meMessageEditor.MessageText); if (SessionAdapter.CheckIfNeedsAuditing(AuditActions.AuditEditMemo)) { SecurityManager.AuditEditMemo(SessionAdapter.GetUserID(), _thread.ThreadID); } // all ok, redirect to thread list Response.Redirect("Messages.aspx?ThreadID=" + _thread.ThreadID + "&StartAtMessage=" + _startAtMessage, false); }
protected void PostMessageHandler(object sender, System.EventArgs e) { int userID = SessionAdapter.GetUserID(); bool result = MessageManager.UpdateEditedMessage(userID, _editMessageID, meMessageEditor.MessageText, meMessageEditor.MessageTextHTML, Request.UserHostAddress, meMessageEditor.MessageTextXML); if (SessionAdapter.CheckIfNeedsAuditing(AuditActions.AuditAlteredMessage)) { SecurityManager.AuditAlteredMessage(userID, _editMessageID); } // all ok, redirect to thread list int startAtMessageID = ThreadGuiHelper.GetStartAtMessageForGivenMessageAndThread(_thread.ThreadID, _editMessageID, SessionAdapter.GetUserDefaultNumberOfMessagesPerPage()); Response.Redirect("Messages.aspx?ThreadID=" + _thread.ThreadID + "&StartAtMessage=" + startAtMessageID + "&#" + _editMessageID, false); }
/// <summary> /// Handles the ItemCommand event of the rpAttachments control. /// </summary> /// <param name="source">The source of the event.</param> /// <param name="e">The <see cref="System.Web.UI.WebControls.RepeaterCommandEventArgs"/> instance containing the event data.</param> protected void rpAttachments_ItemCommand(object source, RepeaterCommandEventArgs e) { int attachmentID = HnDGeneralUtils.TryConvertToInt((string)e.CommandArgument); switch (e.CommandName) { case "Approve": if (_userCanApproveAttachments) { // if auditing is required, we've to do this now. if (SessionAdapter.CheckIfNeedsAuditing(AuditActions.AuditApproveAttachment)) { SecurityManager.AuditApproveAttachment(SessionAdapter.GetUserID(), attachmentID); } MessageManager.ModifyAttachmentApproval(attachmentID, true); } break; case "Revoke": if (_userCanApproveAttachments) { MessageManager.ModifyAttachmentApproval(attachmentID, false); } break; case "Delete": if (_userMayManageAttachments) { MessageManager.DeleteAttachment(attachmentID); } break; } phUploadResult.Visible = false; // rebind attachments. BindAttachments(); }
protected void PostMessageHandler(object sender, System.EventArgs e) { int userID = SessionAdapter.GetUserID(); int messageID = 0; // store the new message as a new thread in the current forum. bool isSticky = meMessageEditor.IsSticky; if (!_userCanCreateNormalThreads && _userCanCreateStickyThreads) { // always sticky isSticky = true; } int threadID = ForumManager.CreateNewThreadInForum(_forum.ForumID, userID, meMessageEditor.NewThreadSubject, meMessageEditor.MessageText, meMessageEditor.MessageTextHTML, isSticky, Request.UserHostAddress.ToString(), _forum.DefaultSupportQueueID, meMessageEditor.SubscribeToThread, out messageID); // invalidate forum RSS in cache ApplicationAdapter.InvalidateCachedForumRSS(_forum.ForumID); if (SessionAdapter.CheckIfNeedsAuditing(AuditActions.AuditNewThread)) { SecurityManager.AuditNewThread(userID, threadID); } // invalidate Forum in ASP.NET cache CacheManager.InvalidateCachedItem(CacheManager.ProduceCacheKey(CacheKeys.SingleForum, _forum.ForumID)); if (meMessageEditor.AddAttachment) { // go to attachment management. Response.Redirect(string.Format("Attachments.aspx?SourceType=2&MessageID={0}", messageID), true); } else { // all ok, redirect to thread list Response.Redirect("Threads.aspx?ForumID=" + _forum.ForumID, true); } }
/// <summary> /// Handles the ItemCommand event of the rpAttachments control. /// </summary> /// <param name="source">The source of the event.</param> /// <param name="e">The <see cref="System.Web.UI.WebControls.RepeaterCommandEventArgs"/> instance containing the event data.</param> protected void rpAttachments_ItemCommand(object source, RepeaterCommandEventArgs e) { int attachmentID = HnDGeneralUtils.TryConvertToInt((string)e.CommandArgument); switch (e.CommandName) { case "Approve": // if auditing is required, we've to do this now. if (SessionAdapter.CheckIfNeedsAuditing(AuditActions.AuditApproveAttachment)) { SecurityManager.AuditApproveAttachment(SessionAdapter.GetUserID(), attachmentID); } MessageManager.ModifyAttachmentApproval(attachmentID, true); break; case "Delete": MessageManager.DeleteAttachment(attachmentID); break; } // done, refresh through redirect to self Response.Redirect("ApproveAttachments.aspx", true); }