[pmwiki-users] Page question

Peter Bowers pbowers at pobox.com
Tue Jun 24 05:25:25 CDT 2008


> Right now we have a "Client" page with a list of our client names. If you click on a name it is linked to a page that requires a password. Each client page has a unique password. We're not using AuthUser, just the default attr for each page.
>
> But what we'd like to do is have the password prompt show up as soon as you click on the main "Clients" page and then depending on the password entered it would take you to that specific clients page.

Here is the solution I suggested earlier, this time coded instead of
pseudo-coded and (briefly and superficially) tested.  I believe it
fits your specs exactly unless I am misunderstanding.

===(snip config.php)===
# $ClientList should hold a list of each homepage for all clients
$ClientList = array('ClientA.Homepage', 'ClientB.Homepage');
Markup('GotoClientPage', 'inline',
	'/\(:goto-client-page:\)/e',
	'GotoClientPage(\$pagename)');
function GotoClientPage($pagename)
{
	global $ClientList;

	$gotopage = null;
	foreach ($ClientList as $homepage) {
	   if (CondAuth($homepage, 'read')) {
	      $gotopage = $homepage;
	      break;
	   }
	}

	if ($gotopage)
	   Redirect($gotopage);
}
===(end snip config.php)===

Then I created the following pages:

ClientA.HomePage
   CONTENT: random content for client A
   ATTR: read passwd=clienta, edit passwd=clientaClientA.HomePage
ClientB.HomePage
   CONTENT: random content for client B
   ATTR: read passwd=clientb, edit passwd=clientb
Client.HomePage
   CONTENT: (:goto-client-page:)
   ATTR: read passwd=clienta,clientb

Now whenever someone navigates to Client.HomePage they will be
prompted for a password.  If they enter clienta they will be sent to
the ClientA.HomePage.  Similarly with the password clientb.

I agree with others that an authuser solution is more elegant, but if
you don't mind keeping the attributes updated on both the pages and
the $ClientList definition in config.php then this should do what you
are looking for.

It has the further advantage of using the standard page-based
passwords rather than something in config.php that has to be kept in
sync to maintain security.  It has the disadvantage that if someone
logs in with multiple passwords it will take them to the first one in
$ClientList.  You may want to have a link to a
Client.HomePage?action=logout somewhere (home pages?) so people can
conveniently log out and in.

-Peter



More information about the pmwiki-users mailing list