Template API for the user
object
The user
object provides the following:
identity
: The identity URL of the userhumanize
: A humanized version of the identity URLname
: The display name of the userprofile
: The user profile; see the Authl documentation for the relevant keys.Note that this will not necessarily be available, depending on how and when the user logged in. For example, if the database has been fully reset (due to e.g. a Publ upgrade or a server migration) since they last logged in, or if the user logged in from a different instance on a load-balanced configuration using a per-instance database, the profile will likely not be present.
groups
: A list of the groups they belong to (not including the user’s identity group)auth_groups
: The full list of matching authentication groups (including the user’s own identity group)is_admin
:True
if the user is a member of the administrative groupauth_type
: How the user’s authentication was obtained; possible values:'session'
: Normal login flow/session cookie'token'
: Bearer token
scope
: The user’s permission scopes, if applicable (typically if the login was via a bearer token)last_login
: The last time the user logged inThis may not be available, per the same rules as
user.profile
last_seen
: The last time the user was active on the sitetoken(lifetime,scope=None)
: A function to generate an HTTP Bearer token for preauthorization.Arguments:
lifetime
: How long the token is good for, in secondsscope
: The access scopes that should be associated with the token
See using bearer tokens for more information.
For the most part you should only use user.name
to address the user, and possibly use user.groups
to check for particular group membership if that is something you want to show them. For example, if you use user groups as a means of managing memberships or rewards or the like, you could do something like:
When extending Publ using additional Python functions, the current user can be retrieved with: