Skip to content

Additional User Attributes

Laritor records an authenticated user with the required id, name, and email fields. You can send additional attributes, such as a user’s role or team, by customizing the data redactor.

If you have not already done so, publish and register a custom data redactor.

Override redactAuthenticatedUser() and return the required user fields along with any additional attributes you want Laritor to receive.

The id, name, and email fields are required. For unauthenticated users, return null for these fields.

public function redactAuthenticatedUser(): array
{
$user = Auth::user();
if ($user) {
return [
'id' => $user->id,
'name' => $user->name,
'email' => $user->email,
'team' => [
'id' => $user->team->id,
'name' => $user->team->name,
],
'role' => $user->role,
];
}
return parent::redactAuthenticatedUser();
}

Choose attributes that are useful for investigating application behavior, and make sure your redactor continues to omit or anonymize any sensitive data your application should not send.