user object provides the following:
identity: The identity URL of the user
humanize: A humanized version of the identity URL
name: The display name of the user
profile: 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)
Trueif the user is a member of the administrative group
auth_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 in
This may not be available, per the same rules as
last_seen: The last time the user was active on the site
token(lifetime,scope=None): A function to generate an HTTP Bearer token for preauthorization.
lifetime: How long the token is good for, in seconds
scope: 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: