smart-screen-lock-pin-auto-lock
Reactive icon

Smart Screen Lock (PIN & Auto-Lock)

Stable version 2.0.0 (Compatible with OutSystems 11)
Uploaded
 on 17 November 2025
 by 
5.0
 (4 ratings)
smart-screen-lock-pin-auto-lock

Smart Screen Lock (PIN & Auto-Lock)

Documentation
2.0.0

🔎 Overview

Smart Screen Lock (PIN & Auto-Lock) is a lightweight security/ privacy component for OutSystems Reactive applications.
It automatically locks the screen after a period of inactivity and requires a PIN to unlock.

In version 2.0, the component now uses secure PIN hashing (SHA-256), ensuring that the raw PIN is never stored or exposed on the client. The lock persists even after a browser refresh, keeping sensitive data protected at all times.

Ideal for HR, Finance, Healthcare, Admin portals, internal dashboards, and any application where confidential information must remain hidden when a user steps away.


🚀 Try Now

A live demo is available:

Try Now Credentials:

(The Try Now link will be automatically generated after Forge approval.)


🛠 Installation & Setup

1️⃣ Install From Forge

Download and install the component into your environment.


2️⃣ Drag the Block into Your Screen

In Service Studio:
Interface → UI Flows → SmartScreenLock → Blocks → ScreenLockBlock

Drop it inside the screen you want to protect.


3️⃣ Configure Block Inputs

InputTypeDescription
PINHashTextSHA-256 hash of the PIN stored in database (never raw PIN).
LockTimeoutIntegerAuto-lock timeout in minutes.

Example:

  • PINHash: "ef92b778bafe..." (SHA-256 hex)

  • LockTimeout: 1 (screen locks after 1 minute of inactivity)


4️⃣ Back-End Logic (Server Side)

Your app needs two simple server actions:

SaveUserLockSettings

Used in your configuration screen where the user sets a new PIN.

Flow:

  1. User types a new PIN in the config screen.

  2. A small JavaScript function on the screen converts the PIN into a SHA-256 hash.

  3. Only the hashed PIN (PINHash) and TimeoutMinutes are sent to the server and stored in the database.

  4. The raw PIN is never stored in the database.

🔐 Note: Hashing is done on the client side using JavaScript (SHA-256), and only the resulting hash is persisted on the server.


GetUserLockSettings

When loading a protected screen:

  • Fetch PINHash and TimeoutMinutes from the database.

  • Pass them into the Smart Screen Lock block as:

    • PINHash → Block.PINHash

    • LockTimeout → Block.LockTimeout

The client-side logic then:

  • Takes the user’s input PIN,

  • Hashes it again in JavaScript (SHA-256),

  • Compares it with PINHash passed from the server.


How the Component Works

🔒 Auto-Lock on Inactivity

  • Timer begins as soon as the screen loads.

  • Any user activity (mouse move, key press, touch) resets the timer.

  • After timeout, the screen locks automatically.


🔁 Lock Persists After Refresh

The lock state is stored using browser sessionStorage.
So even if the user refreshes the tab, the screen remains locked until correct PIN is entered.


🔓 Unlocking with Hashed PIN

  • User enters PIN

  • JS computes: sha256(userInput)

  • Compares against PINHash from server

  • If match → unlock

  • If wrong → error message

Raw PIN is not stored, not returned from DB, and never visible in client code.


🎨 User Interface

The component includes:

  • Full-screen overlay

  • PIN input

  • Unlock button

  • Smooth fade animation

You may customize styling using CSS overrides:

  • .lock-overlay

  • .lock-card

  • .pin-input

  • .unlock-btn


🧪 Testing Guide

  • Set timeout to 1 minute during testing.

  • Save settings → lock should activate after the timeout.

  • Refresh the screen → lock should remain visible.

  • Enter correct PIN → unlock.

  • Enter wrong PIN → error message.


🔐 Security Notes (v2.0)

  • PIN is stored only as SHA-256 hash in DB.

  • Raw PIN is never sent back to client screens.

  • Unlock logic compares hashes, not plain values.

  • The lock is a UX privacy layer, not a replacement for full authentication.

  • For stronger requirements, v3.0 will include optional server-side PIN validation.


📦 Included in the Component

  • Reusable Lock Block

  • Client-side lock engine (JavaScript)

  • UI overlay + CSS

  • SHA-256 hash comparison

  • Demo application


1.0.0

📌 Overview

Smart Screen Lock (PIN & Auto-Lock) is a lightweight security component for OutSystems Reactive applications. It automatically locks the screen after user inactivity and requires the user to enter a PIN to unlock. The lock persists even after a browser refresh, ensuring sensitive information stays protected at all times.

This component is ideal for applications in HR, Finance, Healthcare, Admin Dashboards, and anywhere sensitive information is displayed.


🚀 Try Now

A live demo is available to test the component’s functionality.

🔗 Try Now: (Your Forge Try Now URL will appear automatically once uploaded)

Demo Credentials:


🛠 Installation & Setup

1. Install the Component

Download the component from Forge and add it to your OutSystems environment.

2. Drag the Block into Your Screen

From the Toolbox:
Interface → UI Flows → SmartScreenLock → Blocks → ScreenLockBlock
Drag it into the screen where you want to enable the lock.

3. Set Block Input Parameters

The block provides the following inputs:

ParameterTypeDescription
PINCodeTextThe PIN that the user must enter to unlock the screen. (Example: "1234" or "5698")
LockTimeoutIntegerThe number of minutes before the screen auto-locks due to inactivity. (Example: 1, 5, 10)

Example:

  • PINCode"1234"

  • LockTimeout1 (locks after 1 minute of inactivity)


⚙️ How It Works

🔒 Auto-Lock Behavior

  • A countdown timer begins on page load.

  • Any user activity (mouse movement, keyboard press, touch) resets the timer.

  • When inactivity exceeds the timeout, the screen locks and the PIN overlay appears.

🔁 Lock Persistence

  • If the user reloads the page while the lock is active, the screen remains locked.

  • The user must enter their PIN to unlock again.

🔓 Unlocking

  • User enters the PIN → if correct, screen unlocks.

  • Incorrect PIN resets the input box.


🎨 Styling

The component includes a modern overlay with fade-in/out animation.
You may override its CSS classes to customize colors, alignment, or input styling.

Key classes:

  • .lock-overlay

  • .lock-card

  • .pin-input


🧪 Testing Tips

  • Set LockTimeout = 1 during testing.

  • Refresh the browser → lock should remain active.

  • Test inside Chrome/Edge for accurate inactivity tracking.


🔐 Security Notes 

  • The PIN is not stored on the client.
    It is securely stored in your application’s database and passed only as a parameter to the block.

  • The component does not store or cache the PIN inside the browser.
    It is used only for the unlock comparison on the client side during the active session.

  • For increased security, you may optionally store a hashed version of the PIN in the database and compare using a server-side validation pattern, but this is not required for typical use cases.

  • No external APIs, cookies, or browser storage contain the PIN value.

  • The auto-lock mechanism is stored only as a session state (sessionStorage) to maintain the locked state during refresh — not the PIN.


📦 Included Artifacts

  • Reusable Block (Reactive)

  • Smart Screen Lock JS Engine

  • Overlay UI + CSS

  • Demo Module with login & example screen