internal package
Foswiki::Users internal package
Foswiki::Users ClassMethod
new ($session) ObjectMethod
loadSession() Setup the cgi session, from a cookie or the url. this may return the login, but even if it does, plugins will get the chance to override (in Foswiki.pm)
ObjectMethod
finish() ObjectMethod
loginTemplateName () → templateFile ObjectMethod
supportsRegistration () → boolean ObjectMethod
validateRegistrationField ( $field, $value ) → text Return the registration formfield sanitized by the mapper, or oops thrown to block the registration.
ObjectMethod
initialiseUser ($login) → $cUID Given a login (which must have been authenticated) determine the cUID that corresponds to that user. This method is used from Foswiki.pm to map the $REMOTE_USER to a cUID.
ObjectMethod
addUser($login, $wikiname, $password, $emails) → $cUID $login
- user login name. If undef
, $wikiname
will be used as the login name.
$wikiname
- user wikiname. If undef
, the user mapper will be asked to provide it.
$password
- password. If undef, a password will be generated.
Add a new Foswiki user identity, returning the canonical user id for the new user. Used ONLY for user registration.
The user is added to the password system (if there is one, and if it accepts changes). If the user already exists in the password system, then the password is checked and an exception thrown if it doesn't match. If there is no existing user, and no password is given, a random password is generated.
$login can be undef; $wikiname must always have a value.
The return value is the canonical user id that is used by Foswiki to identify the user.
StaticMethod
mapLogin2cUID( $login ) → $cUID This function maps an arbitrary string into a valid cUID. The transformation is reversible, but the function is not idempotent (a cUID passed to this function will NOT be returned unchanged). The generated cUID will be unique for the given login name.
This static function is designed to be called from custom user mappers that support 1:1 login-to-cUID mappings.
ObjectMethod
getCGISession() ObjectMethod
getLoginManager() → $loginManager ObjectMethod
getCanonicalUserID( $identifier ) → $cUID Works out the Foswiki canonical user identifier for the user who either (1) logs in with the login name $identifier or (2) has the wikiname $identifier.
The canonical user ID is an alphanumeric string that is unique to the login name, and can be mapped back to a login name and the corresponding wiki name using the methods of this class.
Note that if the login name to wiki name mapping is not 1:1, this method will map a wikiname to one of the login names that corresponds to the wiki name, but there is no guarantee which one.
Returns undef if the user does not exist.
ObjectMethod
findUserByWikiName( $wn ) → \@users $wn
- wikiname to look up
ObjectMethod
findUserByEmail( $email ) → \@users $email
- email address to look up
ObjectMethod
getEmails($name) → @emailAddress If $name is a cUID, return their email addresses. If it is a group, return the addresses of everyone in the group.
The password manager and user mapping manager are both consulted for emails for each user (where they are actually found is implementation defined).
Duplicates are removed from the list.
ObjectMethod
setEmails($cUID, @emails) Set the email address(es) for the given user. The password manager is tried first, and if it doesn't want to know the user mapping manager is tried.
ObjectMethod
isAdmin( $cUID ) → $boolean ObjectMethod
isInUserList( $cUID, \@list ) → $boolean The list may contain the conventional web specifiers (which are ignored).
ObjectMethod
getLoginName($cUID) → $login Get the login name of a user. Returns undef if the user is not known.
ObjectMethod
getWikiName($cUID) → $wikiName Get the wikiname to display for a canonical user identifier.
Can return undef if the user is not in the mapping system (or the special case from initialiseUser)
ObjectMethod
webDotWikiName($cUID) → $webDotWiki Return the fully qualified wikiname of the user
ObjectMethod
userExists($cUID) → $boolean Determine if the user already exists or not. A user exists if they are known to to the user mapper.
ObjectMethod
eachUser() → Foswiki::Iterator of cUIDs list of canonical_ids ???
Use it as follows:my $iterator = $umm->eachUser(); while ($iterator->hasNext()) { my $user = $iterator->next(); ... }
ObjectMethod
eachGroup() → $iterator Get an iterator over the list of all the group names.
ObjectMethod
eachGroupMember($group) → $iterator Return a iterator of user ids that are members of this group. Should only be called on groups.
Note that groups may be defined recursively, so a group may contain other groups. This method should only return users i.e. all contained groups should be fully expanded.ObjectMethod
isGroup($name) → boolean Establish if a $name refers to a group or not. If $name is not a group name it will probably be a canonical user id, though that should not be assumed.
ObjectMethod
isInGroup( $cUID, $group, $options) → $boolean Test if the user identified by $cUID is in the given group. Options is a hash array of options effecting the search. Available options are:
expand => 1
0/1 - should nested groups be expanded when searching for the user. Default is 1, to expand nested groups.
ObjectMethod
eachMembership($cUID) → $iterator Return an iterator over the groups that $cUID is a member of.
ObjectMethod
groupAllowsView($group) → boolean returns 1 if the group is able to be modified by the current logged in user
ObjectMethod
groupAllowsChange($group, $cuid) → boolean returns 1 if the group is able to be modified by the current logged in user
ObjectMethod
addToGroup( $cuid, $group, $create ) → $boolean ObjectMethod
removeFromGroup( $cuid, $group ) → $boolean ObjectMethod
checkLogin( $login, $passwordU ) → $boolean Finds if the password is valid for the given user. This method is called using the login name rather than the $cUID so that it can be called with a user who can be authenticated, but may not be mappable to a cUID (yet).
Returns 1 on success, undef on failure.
TODO: add special check for BaseMapping admin user's login, and if its there (and we're in sudo_context?) use that..ObjectMethod
setPassword( $cUID, $newPassU, $oldPassU ) → $boolean If the $oldPassU matches matches the user's password, then it will replace it with $newPassU.
If $oldPassU is not correct and not 1, will return 0.
If $oldPassU is 1, will force the change irrespective of the existing password, adding the user if necessary.
Otherwise returns 1 on success, undef on failure.
ObjectMethod
passwordError($cUID) → $string Returns a string indicating the error that happened in the password handler The cUID is used to determine which mapper is handling the user. If called without a cUID, then the Base mapping is used.
TODO: these delayed error's should be replaced with Exceptions.
returns undef if no error
ObjectMethod
removeUser( $cUID ) → $boolean