Skip to content

Conversation

@HannaFrangi
Copy link

Description

This PR implements a comprehensive screen lock feature that enhances security by allowing users to manually lock their screen or automatically lock after a period of inactivity.

Key Features:

  • Lock Screen UI: A new lock screen page with a password form that requires users to enter their password to unlock
  • Manual Lock: Users can lock the screen via keyboard shortcut (Cmd+Shift+L / Ctrl+Shift+L) or through the profile dropdown menu
  • Auto-Lock: Automatically locks the screen after 30 minutes of user inactivity
  • Inactivity Detection: Implemented useIdle hook that tracks user activity (mouse, keyboard, touch, window events) and detects when the user becomes idle
  • User Experience: Shows a toast notification when the screen is auto-locked due to inactivity

Implementation Details:

  • Created LockScreenProvider context that manages lock state and handles both manual and automatic locking
  • Added useIdle hook to detect user inactivity across multiple event types
  • Integrated lock screen into authenticated layout to protect all authenticated routes
  • Updated profile dropdown to include "Lock Screen" option with keyboard shortcut indicator
  • Lock screen form validates password input and navigates to home page upon successful unlock

Types of changes

  • New Feature (non-breaking change which adds functionality)

Checklist

Further comments

Files Changed:

  • src/features/auth/lock-screen/ - New lock screen feature components
  • src/context/lock-provider.tsx - Lock screen provider with auto-lock and keyboard shortcut handling
  • src/hooks/use-idle.tsx - Custom hook for detecting user inactivity
  • src/components/layout/authenticated-layout.tsx - Integrated LockScreenProvider
  • src/components/profile-dropdown.tsx - Added lock screen menu item
  • src/routes/(auth)/lock-screen.tsx - Lock screen route definition

Security Considerations:

  • The lock screen requires password authentication before allowing access back to the application
  • Auto-lock prevents unauthorized access when the user is away from their device (After 30 min of inactivity)
  • Future enhancement: Could add localStorage flag to prevent navigation to other pages when locked

Testing:

  • Tested manual lock via keyboard shortcut (Cmd+Shift+L)
  • Tested manual lock via profile dropdown menu
  • Tested auto-lock after inactivity period (30 minutes default)
  • Verified lock screen form validation and unlock flow
  • Confirmed activity detection resets the idle timer

Closes: #259

@HannaFrangi
Copy link
Author

@satnaing Please Review!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request]: Add Lockscreen

1 participant