예제 #1
0
    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));
    }
예제 #2
0
    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;
        }
    }
예제 #3
0
    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();
    }
예제 #4
0
    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");
        }
    }