Password on post

May 26, 2011 at 9:13 AM

If i wont set a password for the specificy post (example Wordpress have this function) is possible?

Can help me?

thanks

May 27, 2011 at 11:02 AM

I don't think this is possible in current version of BE.

Dec 20, 2011 at 4:02 PM

Hi All!

I think we have similar requirement.

I want a functionality in which the user goes to a blog and be able the summary the blog.

1. Then he clicks on "More"

2. A pop-up dialog ask for a password

3. The use enters the correct password

4. The user is then shown the entire blog.

"More" is the dividing line between the summary of the blog and the rest of the blog.

Can I make modify the Breakpost Extension for this? But I want the password embedded with the post so each post will have its own password.

Thanks!

Dec 20, 2011 at 6:58 PM

I'm able to create another Extension.

Now I'm stuck with displaying a pop-up dialog inside the code for the Extension. My thought was to re-direct the user to login.aspx so the User can enter his password. But I don't know how to access the Response object within the Extension.

Can someone show me another way please? Maybe a pop-up using Ajax? How?

Thanks!

Coordinator
Dec 20, 2011 at 7:44 PM

You can add javascript to the "more" tag, using "onclick" instead of "href". Then user can click more, enter password in the prompt and script would append this password as query string parameter and redirect to post URL. Not super secure, but will cover basics. If you need more security, you can save password to cookie and then redirect to post where you can check for password from c# code, either in query string or cookie.

Dec 20, 2011 at 11:36 PM

Sorry, rtur. I did not get an e-mail while I coded away.

I created my version of Breakpost Extension:

        switch (e.Location)
        {
            case ServingLocation.PostList:
                AddMoreLink(sender, e);
                break;
            case ServingLocation.SinglePost:
                if (HttpContext.Current.Request.QueryString["1"] == "0")
                {
                    AddMoreLink(sender, e);
                    break;
                }
                else if (HttpContext.Current.Request.QueryString["1"] == "1" || Security.IsAuthenticated)
                {
                    PrepareFullPost(e);
                    break;
                }
                else
                {
                    var post = (Post)sender;
                    HttpContext.Current.Response.Redirect("~/Password.aspx?ReturnUrl=" + post.RelativeLink, true);
                    PrepareFullPost(e);
                    break;
                }
            case ServingLocation.Feed:
                e.Body = e.Body.Replace("[securedmore]", string.Empty);
                break;

Here is the code for the Password.aspx:

    protected void LoginButton_Click(object sender, EventArgs e)
    {
        if (PasswordText.Text == "letmein")
            this.Response.Redirect(this.Request.QueryString["ReturnUrl"] + "?1=1", true);
        else
            InvalidPasswordLabel.Visible = true;
    }

I will modify my code to save the password in a cookie like you said. This way each Secured Post will have it's own password.

 

Thanks for the idea!

 

P.S.: Have I told you guys how much I love Blogengine? There are are smart guys on this project.