Radiator Server Documentation — v10.34.1
Table of Contents

user

User data retrieved from backend.

Fields

FieldTypeAccessDescription
usernamestring?read/writeUsername
passwordstring?write-onlyPassword (write to set, read returns nil)
backendstring?read/writeBackend name that fetched user
groupsstring[]?readUser's groups
rolesstring[]?readUser's roles
radiatordb_rolesstring[]?readUser's RadiatorDB roles

Methods

MethodParametersReturnsDescription
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
clear_radiatordb_roles()--Remove all RadiatorDB roles
append_radiatordb_role(name)RadiatorDB role-Add a RadiatorDB 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