Font Size:
Ask Joget AI

Restrict Joget App Access Based on Device Type

Introduction

Some applications require restricting access based on the type of device used by end-users. For example, allowing access only from mobile devices while blocking access from desktop/laptop browsers.

Joget provides a flexible way to implement this control using UI Permission and a simple BeanShell script.

This article explains how to:

  1. Detect the device type (mobile / desktop) using the browser’s User-Agent.

  2. Restrict entire application access to mobile devices only.

  3. Restrict specific UI menus based on device type.

How does it work?

Detect the device type

Joget’s UI Builder allows custom permission logic via BeanShell scripting. The following script checks the browser’s User-Agent and determines if the user is on mobile or desktop.

import javax.servlet.http.HttpServletRequest;
import org.joget.workflow.util.WorkflowUtil;

HttpServletRequest request = WorkflowUtil.getHttpServletRequest();

public static String getDeviceType() {
    String userAgent = request.getHeader("User-Agent");
    if (userAgent == null) {
        return "unknown";
    }

    String[] mobileKeywords = {"Android", "iPhone", "iPad", "iPod", "BlackBerry", "Opera Mini", "IEMobile", "Mobile"};

    for (String keyword : mobileKeywords) {
        if (userAgent.contains(keyword)) {
            return "mobile";
        }
    }

    return "desktop";
}

// Allow access only if device type is mobile
return "mobile".equals(getDeviceType());

Restrict Specific Menus Inside a UI

If you only want to show or hide certain UI menus based on device type:

  1. In UI Builder, select the UI Category at which the menus are to be restricted are under.
  2. Under Permission Setting, choose BeanShell in the Permission Type dropdown.
  3. Paste the beanshell script, and click Apply Change.

Restrict Entire Application to Mobile Devices Only

To prevent desktop/laptop users from accessing the entire UI, follow these steps:

  1. In UI Builder, click SettingsConfigure Permission.
  2. For Permission Type, select BeanShell from the dropdown.
  3. Paste the script in the Script property, and click Save.

Download sample app

Download the demo app for Restrict Joget App Access Based on Device Type:
Created by hemendra darbar Last modified by Nurkhairini Fitrah on May 12, 2026