protected void Login1_Authenticate(object sender, AuthenticateEventArgs e) { int userlevel = KMAuthentication.AuthenticateUser( KMLogin.UserName, System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(KMLogin.Password, "SHA1")); if (userlevel < 1) { e.Authenticated = false; return; } e.Authenticated = true; string role; if (userlevel == 1) { role = "Admin"; } else { role = "Demo"; } KMAuthentication.CreateAuthenticationTicket(KMLogin.UserName, role); // Need to redirect now as otherwise our cookie is overwritten Response.Redirect(FormsAuthentication.GetRedirectUrl(KMLogin.UserName, true)); }
protected void Page_Load(object sender, EventArgs e) { ((KMBlogMaster)Page.Master).SetTitle("Edit A Category"); if (KMAuthentication.IsUserAdmin(User) == false) { editcategory.DisableSave(); } if (Page.IsPostBack) { return; } editcategory.CategorySaved += this.CategorySaved; int categoryId = Category.GetCategoryIdFromQueryString(Request.QueryString); // Load category Category c = Category.GetCategoryById(categoryId); if (categoryId == 0 || c == null) { lblCategoryDoesNotExist.Text = "The requested category does not exist. Perhaps it has been deleted?"; editcategory.Visible = false; } else { editcategory.Name = c.Name; editcategory.Slug = c.Slug; editcategory.CategoryId = c.Id; } }
public void DeleteComment(object sender, CommandEventArgs e) { if (KMAuthentication.IsUserAdmin(User) == false) { return; } int commentId; if (Int32.TryParse(e.CommandArgument.ToString(), out commentId) == false) { return; } Comment.Delete(commentId); this.LoadPostComments(); }
public void SaveCategory(object sender, EventArgs e) { if (KMAuthentication.IsUserAdmin(Page.User) == false) { return; } if (Page.IsValid == false) { return; } if (this.CategoryId != 0) { Category c = new Category(this.CategoryId, this.Name, this.Slug); if (c) { Category.Edit(c); } } else { Category.Add(this.Name, this.Slug); this.Name = String.Empty; this.Slug = String.Empty; } if (this.CategorySaved != null) { this.CategorySaved(null, null); } if (this.CategoryId != 0) { Response.Redirect("edit-categories.aspx"); } }