Recent Changes - Search:

Cookbook

PmWiki

pmwiki.org

StoredAuthName

Summary: How to set a stored author name to an authenticated user
Version: 0.3 - 16 January 2006
Prerequisites:
Status:
Maintainer:
Categories: Security

Question

How can I set automatically a stored author name to an authenticated user?

Answer

For sites with authenticated users with Cookbook:AuthUser, this script allow you to use author name ($Author) stored in the Site.AuthUser page and to automatically set the author name in the author field in case it's blank.

It does the same job as you can see at Cookbook:RequireAuthor in automatically setting an author name and, optionally, enforcing author tracking but with stored information.

Installation instruction

  1. You need to install authuser.php before. See - Cookbook:AuthUser
  2. Download storedauthname.phpΔ and put it to your /cookbook directory
  3. Add the line below in your local/config.php :
           include_once('cookbook/storedauthname.php');

Usage

To set an author name:

Edit your $SiteGroup.AuthUser page (usually Site.AuthUser) and add lines like this one:

            userid::authorname

Where userid is $AuthId and authorname is $Author separated by two colons. The script set automatically the author name during edition.

If no author name is found, the author name is set to the user id.

To enforce author tracking for authenticated users, you can set the variable $ForceAuthorTracking in your local/config.php just before the include_once function, like this:

            $ForceAuthorTracking=1; # 1 to enable, 0 (default) to disable
            include_once('cookbook/storedauthname.php');

Notes

Tips

Maybe this recipe can help to manage author tracking in a more convenient way by grouping several ideas found in the cookbook:

What you want

What you do

Leave user to be free to provide an author name.

Nothing

User choice his author name but must provide it.

Add to your local/config.php:

  $EnablePostAuthorRequired = 1;

The author name is set as convenience. A user can change it.

Add to your local/config.php:

  include_once('cookbook/storedauthname.php');

The author name is set automatically and user can't change it.

Add to your local/config.php:

  $ForceAuthorTracking=1;
  include_once('cookbook/storedauthname.php');

Versions

This recipe works with PmWiki >= 2.1.beta20. But for previous version you can change The variable $AuthId with $_SESSION['authid'] in the script storedauthname.php.

  • This recipe was last tested on PmWiki version: 2.2.0-beta65
  • This recipe requires at least PmWiki version: 2.1.? and Cookbook:AuthUser
  • This recipe, version 0.1 was installed here the January 10, 2006

Releases

  • January 10, 2006 - v0.1
    First public release. I use it successfully but it has not been tested in a lot of different situations.
  • January 14, 2006 - v0.2
    Fix main condition : users must be authenticated and must be allowed to edit the page for use this script.
  • January 16, 2006 - v0.3
    Fix problems getting user id.

Note June 14, 2006: I've used this cookbook in different production environments for several months without any problems. It should be considered stable.

Comments

Using pmwiki-2.1.11 (with the default template) and this recipe I found that I had to place the include for authuser before the include for storedauthname. If storedauthname was placed first users would have to login in twice. After first login attempt the user would be shown the login page again.

After I figured that out it appears to be working nicely.

Dale Ray (http://www.corantodemo.net/wiki/(approve links)) July 28, 2006

See Also

Contributors

Edit - History - Print - Recent Changes - Search
Page last modified on October 28, 2008, at 12:12 PM