- The members of my band find a 'login' link on our website.
- After logging in, an extra part becomes visible in the menu, which contains pages only logged-in users are able to view.
- The 'login' link turns into a 'logout (username)' link
This is a small HowTo for anyone who wants to achieve it. If you follow these steps it should be a piece of cake!
PLEASE NOTE: I've only tested this on Etomite 0.6.1 Final (Prelude) with the latest patches installed.
PLEASE ALSO NOTE: Despite this howto, the used snippets and methodology is very advanced. Only use the techniques if you have an idea on what you're doing. If you have no experience with using the existing user permissions, please read the documentation on the subject first: http://docs.etomite.com/administration-use...ermissions.html
Here's what I did:
1. I patched my index.php to use the updated checkPermissions API function.
http://www.etomite.com/index.php?s=...ost&p=34849
2. In the Etomite manager, I enabled both 'access permissions' and 'visitor permissions'. To redirect page requests from un-authenticated users I changed the 'access denied message' to
<script type="text/javascript">location.href='accessdenied.html'</script>where 'accessdenied.html' is the alias + friendly URL suffix of the page where I tell people the have to log in and redirect them to the login page.
3. I added the snippet 'authenticate_visitor' (http://www.etomite.com/index.php?showtopic=4867) and I patched it with the recent security fix (http://www.etomite.com/index.php?showtopic=5706). Then I made a slight modification. I changed the line
// PROCESSING STARTS HERE
// if the user is authenticated and no destination was provided, provide a logout button.
// this conditional code block is optional and can be remarked or bypassed
if($_SESSION['validated'] && $use_logout)
{
if(isset($_POST['logout'])) $etomite->userLogout($url,$id,$alias="");
to// PROCESSING STARTS HERE
// if the user is authenticated and no destination was provided, provide a logout button.
// this conditional code block is optional and can be remarked or bypassed
if($_SESSION['validated'] && $use_logout)
{
if(isset($_POST['logout'])||isset($_GET['logout'])) $etomite->userLogout($url,$id,$alias="");
4. I created a new user role 'member' with no manager permissions at all.
5. I created a new usergroup called 'members' and a documentgroup 'restricted memberpages' and matched the two.
6. I created a bunch of users for my members with the role 'member' and gave them 'members' (the usergroup) permissions.
7. I created a login page (login.html) and a page with an 'Access Denied' message (accessdenied.html), both NOT CACHABLE and containing a call to the login snippet: [ ! authenticate_visitor ! ]
8. I once again read the tutorial Ralph wrote on the subject (http://dahlgren.slyip.com/e_v_a_101.html) and amended my menu snippet. I'm using the MollioSecondary menu and have attached the edited snippet. It now always displays the documents that don't require authentication. When logged in, it displays the non-authenticated documents, the documents that only require authentication and the documents that require permission and the logged in user happens to have the right ones.
Ralph also edited the ListMenu snippet to do the same (http://www.etomite.com/index.php?s=...ost&p=34849) so that should help in amending your own menu snippet. If you don't succeed, attach the code here (don't paste it in your post, I'll delete those) and we'll help.
9. Finally, I added the documents and folders I want to protect from the public. On the 'publication' tab I checked 'Authenticate?' and on the 'permissions' tab I checked 'restricted memberpages' (the documentgroup I created earlier).
10. To make thinks a bit fancy, I created a little snippet I called LoginOut, which is attached to this post and I include it like [ ! LoginOut ! ] somewhere in my template.
11. Unless I've forgotten something, you should be up and running!
Attached Files
Edited by Jelmer, 01 August 2006 - 08:39 PM.













