Lua script context API - User sub-context
user
User data retrieved from backend.
Fields
| Field | Type | Access | Description |
|---|---|---|---|
username | string? | read/write | Username |
password | string? | write-only | Password (write to set, read returns nil) |
backend | string? | read/write | Backend name that fetched user |
groups | string[]? | read | User's groups |
roles | string[]? | read | User's roles |
Methods
| Method | Parameters | Returns | Description |
|---|---|---|---|
clear_groups() | - | - | Remove all groups |
append_group(name) | group name | - | Add a group |
clear_roles() | - | - | Remove all roles |
append_role(name) | role name | - | Add a role |
Example
local context, previous = ...
local user = context.user
if user.username then
-- Add user to a group based on realm
if context.aaa.identity and context.aaa.identity:match("@admin%.") then
user:append_group("administrators")
user:append_role("admin")
end
end
return previous