Identity, permissions, and real-time updates
Helpdesk uses the framework session as the base for identity, then adds desk roles, agent records, customer roles, and record rules to control access. The desk loads this identity once, keeps user state in shared stores, and uses a socket connection to share changes such as availability, ticket presence, typing, comments, and notifications. See the broader agent desk platform page and the desk application shell page for the surrounding product and page lifecycle.
Identity and access model
The system separates three related questions: whether a browser has a valid session, whether that session may use the Helpdesk desk, and whether it may act on a specific record. This separation lets customer users keep access to customer routes while desk users receive the wider agent experience.
flowchart TD
A[Framework session cookie] --> B[User identity payload]
B --> C{Desk access?}
C -->|No| D[Customer portal routes]
C -->|Yes| E[Desk routes]
E --> F[Role and agent checks]
F --> G[Record-level permission checks]
B --> H[Shared user and status state]
H --> I[Socket events]
Session identity
The session API is the source of truth for the signed-in user. helpdesk.api.auth.get_user returns the identity and the access facts needed by the client, including desk access, admin and manager state, agent-record presence, teams, language, and current availability. The client auth store fetches this payload before route checks and treats the session cookie as the logged-in signal.
The same auth API accepts profile changes for the current user. It validates uploaded images and time zones, then keeps the related contact profile in step with the user profile.
Login and logout use full-page framework flows. An unauthenticated route redirects to /login and preserves the requested Helpdesk path so the user can return after sign-in. Logout clears the local identity and then sends the browser to the login page.
The agent-only email session API supplies the signed-in agent's email details for desk email actions. It combines the user's signature and address with linked user email accounts and enabled outgoing accounts.
References: helpdesk/…/auth.py• L9-90 helpdesk/…/auth.py• L93-143 helpdesk/…/auth.py• L146-178 desk/…/auth.ts• L6-79 desk/…/index.ts• L229-255
Access controls
Application access starts with an allowed role or the Administrator account. Route checks then distinguish desk users from customer users. Server-side decorators and framework permission hooks enforce the same boundary for API calls, so hiding a route is not the security control.
Record access adds context to the role. A ticket can be available to its contact, reporter, owner, customer manager, or an agent whose team or assignment matches the ticket when team restrictions are enabled. Agent records are readable for shared presence and assignment views, but an agent can change only their own record unless they are an agent manager.
| Access layer | Main question | Examples |
|---|---|---|
| Application | May this user enter Helpdesk? | Agent, Agent Manager, System Manager, customer roles |
| Route | Which experience may this user open? | Desk routes or customer portal routes |
| API action | May this user call this operation? | Agent-only and agent-manager-only actions |
| Record | May this user read or change this item? | Ticket contact, customer manager, team agent |
References: helpdesk/…/permission.py• L3-17 helpdesk/utils.py• L46-73 helpdesk/utils.py• L176-221 helpdesk/hooks.py• L106-118 helpdesk/…/hd_ticket.py• L1335-1382 helpdesk/…/hd_agent.py• L104-115
Persona capture
Here, a persona is the onboarding questionnaire state for the Helpdesk site. It is not an access role. An eligible desk administrator sees the onboarding route only when telemetry is enabled and the questionnaire is not marked complete.
The client checks a browser marker first and falls back to the server flag in the user payload. Completion records the site setting and can use the submitted organization name as the Helpdesk brand. This prevents repeated prompts while keeping the server as the durable source for later sessions.
References: desk/…/persona.ts• L4-59 desk/…/index.ts• L205-212 helpdesk/…/auth.py• L52-76 helpdesk/…/onboarding.py• L6-21
Desk user state
The desk keeps identity details, the active user directory, and agent availability in shared client stores. These stores support features such as assignment, profile display, role labels, and presence without making each page rebuild the same user context.
User directory
The session user API returns enabled framework users with their highest relevant Helpdesk role. The role order is Manager over Agent over Guest. The client caches the result by user name and supplies a small fallback identity when a page references a user that is not in the loaded list.
This directory is available only to an agent session. An authentication error sends the browser back to login, which keeps stale user data from being treated as a valid desk session.
References: helpdesk/…/session.py• L6-49 desk/…/user.ts• L7-76
Agent availability
Agent availability is the live state shown beside agents and in the current user menu. The available status list defines which values can be selected and how they appear. The current value is seeded from the session payload, then updated for every connected client when an agent record changes.
A status change is optimistic in the current client. The client restores the prior value if the server rejects the write, while the server validates the status and sends the authoritative value and change time after a successful update. Users without an HD Agent record do not have an agent availability state.
References: helpdesk/…/hd_agent.py• L12-23 helpdesk/…/hd_agent.py• L47-89 desk/…/agentStatus.ts• L39-121 desk/…/AvailabilityMenu.vue• L1-27
Notifications
Notifications are durable, user-targeted records that give the desk a history of work that needs attention. The notification controller is tied to the signed-in user and shared socket, so it provides unread counts and refreshes the panel as notification data changes.
The main notification types are Assignment, Mention, Reaction, and Ticket Reopened. The panel can show all or only unread records, and it can narrow the list by type. Opening the panel marks notifications as seen; users can mark one item or all items as read. Mentions can also produce email when the site has not disabled that workflow.
Selecting a ticket notification opens the ticket. A comment notification also opens the activity view and identifies the source comment, which lets the desk place the user at the relevant activity. Reactions update an existing notification for the comment owner when possible, then publish a socket signal so other desk clients reload their notification view.
sequenceDiagram
participant Actor as Desk user
participant Server as Helpdesk server
participant Store as HD Notification
participant Clients as Recipient desk clients
Actor->>Server: Mention or react on ticket
Server->>Store: Create or update recipient notification
Server-->>Clients: Real-time refresh signal
Clients->>Store: Reload recipient notifications
Actor->>Clients: Open notification or mark read
Clients->>Server: Clear matching unread records
References: helpdesk/…/hd_notification.json• L20-81 helpdesk/…/hd_notification.py• L5-66 helpdesk/…/utils.py• L4-22 helpdesk/…/hd_ticket_comment.py• L143-186 desk/…/notification.ts• L8-71 desk/…/NotificationFilters.vue• L21-49 desk/…/Notifications.vue• L13-95
Real-time synchronization
The desk opens one Socket.IO connection for the current site and shares it through the global client store. The connection carries session credentials and retries a limited number of times. Server events use either a site room, a user room, or an open-ticket room so a change reaches the users who need it.
Socket transport
The socket URL is built from the browser host and the current site name. The framework session remains the identity for the connection because the client sends credentials with the socket handshake. Server code also uses the same document-room naming scheme as framework document updates.
Framework-side events use publish_event with delivery after the related database commit. This ordering keeps clients from reloading data before the saved change is visible. The custom Socket.IO handlers cover ticket collaboration signals that do not need a stored record.
References: desk/…/socket.ts• L1-26 desk/…/globalStore.ts• L4-12 helpdesk/utils.py• L76-101 realtime/handlers.js• L1-4 realtime/handlers.js• L106-112
Ticket collaboration
Ticket collaboration is scoped to the open ticket. A client joins the ticket room when it starts viewing and leaves it when viewing stops. The room then shares the current viewer list, field-change signals, and typing state with the other viewers.
Typing state is short lived. The client announces the start once, refreshes its local activity timer while the editor is active, and sends a stop event when the user stops or leaves. Each client removes its own user from the viewer and typing displays so the UI describes other collaborators.
References: realtime/handlers.js• L6-73 realtime/handlers.js• L75-103 desk/…/realtime.ts• L5-51 desk/…/realtime.ts• L54-147
Event-driven refreshes
Stored changes use events as invalidation signals rather than as a second copy of the full record. For example, a ticket comment event identifies the ticket and a reaction event identifies the comment and ticket. The receiving store or page then reads the current record through the normal API.
Agent availability follows a stronger live-state path because the event includes the agent, status, and change time. The availability store merges these events into a shared map, while notification and configuration stores use events to reload their cached resources.
References: helpdesk/…/hd_ticket_comment.py• L26-47 helpdesk/…/hd_ticket_comment.py• L96-103 desk/…/agentStatus.ts• L52-65 desk/…/notification.ts• L54-68 desk/…/config.ts• L1-43
Change checklist
When these files or sections are changed, remember to consider these:
- Keep the fields returned by
helpdesk.api.auth.get_useraligned with the auth store and route guards. A missing access flag can change the user’s whole portal experience. - Keep the agent-only email session response aligned with the desk email actions that consume the signature, user address, linked email accounts, and outgoing account list.
- Keep role names and role priority aligned across application access, user listing, invitations, and client role labels.
- When changing ticket permission rules, review both single-record checks and list query conditions. They must not expose different ticket sets.
- When changing an event name or payload, update both the publisher and every socket listener. Preserve the ticket, user, and agent identifiers used to scope live state.
- Keep availability validation, optimistic client state, and the authoritative availability event in the same contract.
- Keep notification type values aligned between server-created records, notification filters, and the notification controller.
- Preserve the ticket and source-comment mapping used by notification links when notification references or read rules change.
- Keep notification read filters aligned with the recipient and reference fields used by the notification controller.
- Keep socket site naming and session credentials aligned with the deployment’s Socket.IO namespace.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| Auth payload fields no longer match the auth store | Route guards can send a valid user to the wrong portal or deny desk access | Treat get_user and useAuthStore as one contract |
| The agent email session response changes without its desk email consumer changing | Agents can see incomplete sender data or fail to send from an expected account | Treat the email response fields and email actions as one contract |
| A ticket permission rule changes without its list query rule | A user can see a ticket in a list but fail to open it, or open a ticket missing from the list | Review record checks and permission_query together |
| Socket event names or room IDs differ between client and server | Presence, typing, availability, or refresh signals stop without a clear API error | Keep event names and room construction shared by both sides |
| Availability write is rejected after an optimistic update | The current user sees a status that the server did not save | Roll back on write failure and accept the later server event as authoritative |
| Notification read filters omit the ticket or comment reference | Unread items remain or unrelated notifications are marked read | Keep user_to, reference_ticket, and reference_comment filters aligned |
| A notification type changes on the server but not in the filter list | Users cannot find that notification through its category filter | Keep notification log types and filter values as one contract |
| A notification link loses its ticket or source-comment reference | Clicking a notification opens the wrong place or no ticket at all | Keep routeFor aligned with notification document and source fields |
Key files
| File | Why to read it |
|---|---|
| desk/…/auth.ts | Main client contract for session identity and access facts |
| helpdesk/…/auth.py | Server source for identity, profile, and agent email payloads used by route guards, stores, and desk email actions |
| desk/…/index.ts | Portal boundary between unauthenticated, customer, desk, and onboarding routes |
| helpdesk/…/permission.py | Application-level role allow-list |
| helpdesk/…/hd_ticket.py | Ticket record access and team restriction rules |
| desk/…/user.ts and helpdesk/…/session.py | Shared user directory and role labels |
| desk/…/agentStatus.ts and helpdesk/…/hd_agent.py | Agent availability state and its live update contract |
| desk/…/notification.ts | Signed-in user's notification state, filters, unread count, and ticket links |
| desk/…/Notifications.vue and desk/…/NotificationFilters.vue | Notification panel actions and read/type filters |
| helpdesk/…/hd_notification.py | Notification creation, update, and email behavior |
| desk/…/socket.ts and realtime/handlers.js | Socket connection and ticket collaboration events |
| desk/…/realtime.ts | Client-side viewer, field-update, and typing synchronization |
| helpdesk/…/hd_ticket_comment.py | Stored comment and reaction events that refresh ticket clients |