Password Protected Extension

26. August 2009 4:04 PM

Back to few days ago, a friend of mine who also using .NET BlogEngine was asking me about how to modify the code to make it support password protected post/page.

After I look into details about how am I going to kick start... and I found the best implementation is writing an 'Extension'. That how the 'PasswordProtected' extension was borned! See the sample post here!

Before you can enjoy the password protection features, you are require to defined more roles besides both the existing 'Administrators' and 'Editors' in the \App_Data\roles.xml data file as show in the screen shot below,

Note, after you have updated the roles.xml, you are require to restart the IIS before you can see the new defined role appear on the users screen. Then, you are begin to create more users under any others roles other then 'Administrators' and 'Editors'. As the best practice is using email address as the login ID, and further defined the nickname under the respective profile, so a correct nickname will be display on the comments instead the login ID (email address).

Next is download this extension and upload to your respective .NET BlogEngine folders.

  1.   Copy the 'PasswordProtected.cs' source fiel to '\\blog\App_Code\Extensions' folder.
  2.   Copy the 'protected.png' image file to '\\pics' folder (you may change this image).

 

Last thing you need to know is the syntax... a syntax that make your post/page become password protected!

  [protected:on|off;roles:role1,role2,role3]

Below is some of the self explain combination,

  • Turn the password protection off. 
      [protected:off]
  • Sample syntax for password protection enabled and only limit to all users with under role of 'role2'.
      [protected:on;roles:role2]
  • Another sample syntax with password protection enabled and limit to all users with under role of 'role1' and 'role3'.
      [protected:on;roles:role1,role3]


Note
, both 'Administrators' and 'Editors' role will overwrite the defined role in the above syntax.


 

 PasswordProtected.v1.0.826.1.zip (37.48 kb)

BlogEngine.NET ,

Comments

Add comment




  Country flag

biuquote
Loading