1.2.7.4 AuthUser Objects

The user object is retuned by AuthAdmin and AuthManager objects' user() method and should not be created directly.

The attributes firstname, surname, email, password, group and active can all be directly set and their values will be updated in the database.

The class has the following properties:

class AuthUser

username
The username of the user. Usernames are case insensitive but are always stored and returned as lowercase. This means that if you want to compare a username from a database with a value entered by a user, you should first convert the value entered by a user to lowercase like this: username = username.lower()

The username of a user cannot be changed.

password
The user's password, 1-255 characters.

firstname
The user's firstname, 1-255 characters. Optional

surname
The user's surname, 1-255 characters. Optional

email
The user's email address, max 255 characters. Optional

group
The user's group, max 255 characters or None if no group has been set. Optional

active
True or False depending on whether the user is considered active.

levels
The access levels for the applications the user has access to as a dictionary with application names as keys. Levels can only be set through the setLevel() method of AuthManager or AuthAdmin objects. Warning: Changing the value stored in levels will not update the database.

roles
The user's roles for each application as a dictionary with application names as keys. Roles can only be set through the setRole() method of AuthManager or AuthAdmin objects. Warning: Changing the value stored in roles will not update the database.

authorise( [app=None], [level=None], [role=None], [active=1], [group=[]])
Return True if the user is authorised for the options specified, False otherwise.

If active=0 only disabled accounts are authorised, if active=None both active and disabled accounts are authorised. If group is not specified all groups are authorised, if group=None only users not in a group are authorised, otherwise only users in the group specified are authorised. If level or role are specified, app must be specified too.