webiste/docs: improve user ref doc (#16779)

* WIP

* WIP

* Update website/docs/users-sources/user/user_ref.mdx

Co-authored-by: Tana M Berry <tanamarieberry@yahoo.com>
Signed-off-by: Dewi Roberts <dewi@goauthentik.io>

* Language change

* Update website/docs/users-sources/user/user_ref.mdx

Co-authored-by: Tana M Berry <tanamarieberry@yahoo.com>
Signed-off-by: Dewi Roberts <dewi@goauthentik.io>

---------

Signed-off-by: Dewi Roberts <dewi@goauthentik.io>
Co-authored-by: Tana M Berry <tanamarieberry@yahoo.com>
This commit is contained in:
Dewi Roberts
2025-09-17 00:54:00 +03:00
committed by GitHub
parent cf0afd98e3
commit b5ec7df9d1

View File

@@ -17,7 +17,12 @@ The User object has the following properties:
- `path`: User's path, see [Path](#path)
- `attributes`: Dynamic attributes, see [Attributes](#attributes)
- `group_attributes()`: Merged attributes of all groups the user is a member of and the user's own attributes. Read-only.
- `ak_groups`: This is a queryset of all the user's groups.
- `ak_groups`: This is a queryset of all the user's direct groups.
- `all_groups()`: This is a queryset of all the user's direct and indirect groups.
:::note Clarifying direct vs indirect group membership
A user is a member of a group (direct member). If that group in turn has a parent group, then the user is an indirect member of that parent group.
:::
## Examples
@@ -25,7 +30,7 @@ These are examples of how User objects can be used within Policies and Property
### List a user's group memberships
Use the following example to list all groups that a user object is a member of:
Use the following example to list all groups that a user object is a direct member of:
```python
for group in user.ak_groups.all():
@@ -34,7 +39,7 @@ for group in user.ak_groups.all():
### List a user's group memberships and filter based on group name
Use the following example to list groups that a user object is a member of, but filter based on group name:
Use the following example to list groups that a user object is a direct member of, filtered based on group name:
```python
user.ak_groups.filter(name__startswith='test')
@@ -42,7 +47,7 @@ user.ak_groups.filter(name__startswith='test')
### List a user's group memberships including parent groups
Use the following example to list all groups that a user object is a member of, including parent groups:
Use the following example to list all groups that a user object is a direct and indirect member of:
```python
groups = [group.name for group in request.user.all_groups()]