I want to use AuthUser for identity-based authorization but need to have new members create their own accounts, and I would like some tools to simplify administration of their accounts. How can I do it?
Use the FAST Membership cookbook recipe. Based on the HtpasswdForm code, it enables new users to create their own account automatically as a new feature to those already provided by the base recipe (authenticated users allowed to change their password, web interface to manage accounts).
Alternately use newuser.php below for a few extra features, especially if you want to track new member data option. You will need to combine this with HtpasswdForm for the admin and change password features as it only sets up new accounts.
How to Install
- Download membership-1.1.phpΔ and save it in the cookbook directory (rename it membership.php).
- Make sure AuthUser is enabled by putting
- Add a line pointing to the desired location of your password file in config.php file, such as
$AuthUser['htpasswd'] = '../members.htpasswd';Note: in a farm installation, multiple wikis can share one membership list, or each can have their own.
include_once("$FarmD/cookbook/membership.php");in a local configuration file. For best security, only include this script for pages it is used on.
(:membership:)into one or more wiki pages.
How it Works
This markup is actually three in one.
- If inserted into a page where the viewer is not authenticated, a small form pops up allowing them to choose a members name and password (which must be entered twice). If an existing name is entered, they will be alerted to that fact, and asked to choose another.
- If viewed by an authenticated user, it becomes a form allowing them to change their password. They must enter their old password for the change to take effect.
- If viewed by someone with Admin permissions, it shows a list of all current members, with options to change member names, passwords, delete accounts, create accounts. Very simple, but functional web interface.
You may wish to use this on a page in three separate groups of your site: a welcome group for non members (to register), a members group (to update their passwords), and in the admin section (for administrator use). Wherever it is located however, the form you see will depend on your authentication/authorization as you view the page.
To set the redirect page (especially useful for when members create new accounts, use either of the following:
(:membership page=Site.NewMember:)will redirect a new member to Site.NewMember.
- Set $MembershipCreatedPage in
local/config.php with some page name.
My goal in modifying this script was primarily to allow new members to create their own accounts instantly--in the context of AuthUser. It does that job nicely.
My goal in releasing this as a separate recipe was to see it hopefully expand into a more complete script by suggesting a few "development" goals, and inviting others to join in helping with them. The goals seem fairly simple--but I'm not much of a coder. Someone else could probably make most of these changes in a snap. If you would like to help with this recipe, here are several features I would like to see added:
- Use this form to store email addresses, as a third column in the password file.
- Create a way for a member to be reminded of their password by email if they forget it (or possibly have their password re-set, with a new temporary password sent by email).
- Use a better system to verify members' emails. See my comments below on a poor, but functional solution. I hear Pm may be working on a membership solution that may deprecate all this.
- AuthUser Pm's identity based password script, comes already in PmWiki.
- HtpasswdForm The recipe this one is based on.
- UserAuth Another membership solution not using AuthUser
- ZAP A different approach to member management that is built on AuthUser.
2006/03/18 Initial release.
2006/06/?? Version 1.1 Ben Wilson added namespace collision provision with htpasswd file and optional parameter for setting a redirect page.
This recipe was only tested on PmWiki version: 2.1. Should work on any version HtpasswdForm works on. You may wish to see that recipe if you have any technical difficulties.