userUser

Understanding the User object returned from authentication.

circle-info

When to use: After login or validate, to access user properties and check permissions.

chevron-rightPrerequisiteshashtag
  • Completed Login

  • Have a user object from authenticate() or validate_session()

5-Line Core

# User has identity info
print(user.id, user.email, user.display_name)
# User has authorization info
print(user.roles, user.permissions)
# User has helper methods
user.has_permission("documents:read")

User Properties

Property
Type
Description

id

str

Unique user identifier

email

str

User's email address

display_name

str | None

Display name

username

str | None

Username

roles

list[str]

Assigned roles

permissions

list[str]

Direct permissions

organization_id

str

Current organization

is_active

bool

Account active status

created_at

datetime

Account creation time

User Methods

Method
Returns
Description

has_permission(perm)

bool

Check single permission

has_all_permissions([...])

bool

Check all permissions (AND)

has_any_permission([...])

bool

Check any permission (OR)

has_role(role)

bool

Check raw role string

has_standard_role(role)

bool

Check standard role with hierarchy

get_standard_roles()

list

Get mapped standard roles

Step-by-Step

1

Access Identity Info

2

Access Authorization Info

3

Check Permissions

4

Check Roles

5

Expected Output

circle-check

Complete Example

Next Steps


circle-info

Found an issue on this page? Report it on our feedback formarrow-up-right.

Last updated

Was this helpful?