-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Adds background worker to check timeout state #19702
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds a background shared worker to monitor token expiration, integrates a session timeout controller in the auth context, implements a modal for timeout warnings, updates Vite configs to support a custom base path, and includes new translations for timeout messages.
- Enable WebWorker support in TS config
- Introduce SharedWorker token-check logic and session timeout controller
- Add modal UI and localization entries for session expiration warnings
Reviewed Changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 5 comments.
Show a summary per file
File | Description |
---|---|
src/Umbraco.Web.UI.Client/tsconfig.json | Added WebWorker to lib for shared worker support |
src/Umbraco.Web.UI.Client/src/vite-config-base.ts | Added optional base argument to default Vite config |
src/Umbraco.Web.UI.Client/src/packages/core/vite.config.ts | Set base path for core package builds |
src/Umbraco.Web.UI.Client/src/packages/core/auth/workers/token-check.worker.ts | Implemented shared worker to periodically check token state |
src/Umbraco.Web.UI.Client/src/packages/core/auth/modals/umb-auth-timeout-modal.token.ts | Defined UmbModalAuthTimeoutConfig and modal token |
src/Umbraco.Web.UI.Client/src/packages/core/auth/modals/umb-auth-timeout-modal.element.ts | Built the countdown modal UI for session timeout |
src/Umbraco.Web.UI.Client/src/packages/core/auth/modals/manifests.ts | Registered the timeout modal in the modal manifests |
src/Umbraco.Web.UI.Client/src/packages/core/auth/modals/index.ts | Exported the new timeout modal token |
src/Umbraco.Web.UI.Client/src/packages/core/auth/controllers/auth-session-timeout.controller.ts | Added controller to wire the token-check worker and modal |
src/Umbraco.Web.UI.Client/src/packages/core/auth/auth.context.ts | Instantiated session timeout controller in the auth context |
src/Umbraco.Web.UI.Client/src/packages/core/auth/auth-flow.ts | Replaced #tokenResponse with UmbObjectState and streams |
src/Umbraco.Web.UI.Client/src/assets/lang/en.ts | Added English timeout warning translations |
src/Umbraco.Web.UI.Client/src/assets/lang/de.ts | Added German timeout warning translations |
src/Umbraco.Web.UI.Client/src/assets/lang/da.ts | Added Danish timeout warning translations |
Comments suppressed due to low confidence (2)
src/Umbraco.Web.UI.Client/src/packages/core/auth/controllers/auth-session-timeout.controller.ts:41
- This comment is incomplete. Either finish describing the action (e.g., "Post the new token to the worker") or remove it to avoid confusion.
// Post the new
src/Umbraco.Web.UI.Client/src/packages/core/auth/workers/token-check.worker.ts:1
- The new shared worker logic should have accompanying unit tests to validate expiration detection, refresh messaging, and logout signaling.
import type { TokenResponse } from '@umbraco-cms/backoffice/external/openid';
src/Umbraco.Web.UI.Client/src/packages/core/auth/workers/token-check.worker.ts
Outdated
Show resolved
Hide resolved
src/Umbraco.Web.UI.Client/src/packages/core/auth/workers/token-check.worker.ts
Outdated
Show resolved
Hide resolved
src/Umbraco.Web.UI.Client/src/packages/core/auth/workers/token-check.worker.ts
Outdated
Show resolved
Hide resolved
src/Umbraco.Web.UI.Client/src/packages/core/auth/workers/token-check.worker.ts
Outdated
Show resolved
Hide resolved
src/Umbraco.Web.UI.Client/src/packages/core/auth/modals/umb-auth-timeout-modal.element.ts
Outdated
Show resolved
Hide resolved
…-check.worker.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
….com/umbraco/Umbraco-CMS into v16/feature/check-timeout-and-logout
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested out, works as advertised! 🚀
…ght does not seem to like Web Workers
Description
This pull request introduces session timeout handling and token management improvements across multiple files, along with localization updates for timeout-related messages. The key changes include implementing a session timeout controller, enhancing token state management, and adding localized messages for session expiration warnings.
How to test
Umbraco:Global:TimeOut
to something low like"00:02:00"
, which is two minutes. Then log in and wait 30 seconds, you should now see a modal counting downSequence
User:
System:
Changes
Session Timeout Handling:
src/Umbraco.Web.UI.Client/src/packages/core/auth/controllers/auth-session-timeout.controller.ts
: AddedUmbAuthSessionTimeoutController
to manage session timeout and token expiration using a shared worker. It handles user logout, token refresh, and modal display for user decisions.src/Umbraco.Web.UI.Client/src/packages/core/auth/auth.context.ts
: Integrated the session timeout controller into the authentication context.Token Management Enhancements:
src/Umbraco.Web.UI.Client/src/packages/core/auth/auth-flow.ts
: Replaced the#tokenResponse
property withUmbObjectState
for better state management and added observable streams for token updates. Updated token-related methods to use the new state management approach. [1] [2] [3] [4] [5] [6] [7] [8] [9]Localization Updates:
src/Umbraco.Web.UI.Client/src/assets/lang/da.ts
: Added Danish translations for session timeout warnings.src/Umbraco.Web.UI.Client/src/assets/lang/de.ts
: Added German translations for session timeout warnings.src/Umbraco.Web.UI.Client/src/assets/lang/en.ts
: Added English translations for session timeout warnings.Modal and Worker Implementation:
src/Umbraco.Web.UI.Client/src/packages/core/auth/modals/umb-auth-timeout-modal.element.ts
: Implemented a modal element for session timeout warnings, allowing users to choose between logging out or staying logged in.src/Umbraco.Web.UI.Client/src/packages/core/auth/workers/token-check.worker.ts
: Added a shared worker to periodically check token expiration and trigger appropriate actions (logout or refresh).Build Configuration:
src/Umbraco.Web.UI.Client/src/packages/core/vite.config.ts
: Updated the Vite configuration to set a base path for the core package.src/Umbraco.Web.UI.Client/src/vite-config-base.ts
: Added support for configuring thebase
path in the default Vite configuration.