Font Size:
Ask Joget AI

Displaying Logged-In Users in Joget Using Audit Trail

Introduction

This article shows how to identify currently logged-in users in Joget by analyzing login and logout records stored in the system audit trail. Since Joget does not provide a built-in feature to list active user sessions, this solution derives the information by checking each user’s most recent authentication activity.

How does it work?

Joget records user authentication activities in the database table wf_audit_trail. Each login and logout action generates an audit entry with:

  • Username (stored within the message field).
  • Method (authenticate for login, logout for logout).
  • Timestamp of the action.

This solution works by:

  1. Extracting usernames from the audit trail message.
  2. Retrieving both login (authenticate) and logout (logout) events.
  3. Identifying the latest activity for each user.
  4. Considering a user as currently logged in if their most recent activity is authenticate.

The result is a list of users whose last recorded action was a successful login and who have not logged out yet.

This approach provides a logical approximation of logged-in users based on audit data and does not track real-time session status.

Configure the Data Binder

  1. In the App Composer page, click Create New under List Builder.
  2. Enter a suitable name (e.g., Currently Logged-In Users).
  3. In List Builder, navigate to the Data tab.
  4. For the Select Source of data dropdown, select Database SQL Query.
  5. Paste the following SQL query:
    SELECT
        username,
        MAX(timestamp) AS login_time
    FROM (
        SELECT
            SUBSTRING(
                message,
                INSTR(message, 'user ') + 5,
                INSTR(message, ' (') - INSTR(message, 'user ') - 5
            ) AS username,
            method,
            timestamp
        FROM wf_audit_trail
        WHERE method IN ('authenticate', 'logout')
    ) t
    GROUP BY username
    HAVING
        SUBSTRING_INDEX(
            GROUP_CONCAT(method ORDER BY timestamp DESC),
            ',', 1
        ) = 'authenticate'
    ORDER BY login_time DESC
    
  6. Drag and drop the username list element to display the user’s Username.
  7. Drag and drop the login_time list element to display the Last Login Time.
  8. Save the configuration.

Add to UI (Optional)

  1. Go to UI Builder.
  2. Add a List Menu UI element.
  3. Select the Currently Logged-In Users list.
  4. Click Save and publish the UI.

Download Sample App

Download the demo app of Displaying Logged-In Users in Joget Using Audit Trail:
Created by hemendra darbar Last modified by Siti Noratiqah on May 25, 2026