Skip to content

Commit

Permalink
fix: prevent unintentional logout when applock is active [15545] (#18698
Browse files Browse the repository at this point in the history
)
  • Loading branch information
V-Gira authored Feb 3, 2025
1 parent b41b34f commit 0cf6a90
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/script/page/AppLock/AppLock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ const AppLock: React.FC<AppLockProps> = ({
'isAppLockEnforced',
]);

// We log the user out if there is a style change on the app element
// i.e. if there is an attempt to remove the blur effect
const {current: appObserver} = useRef(
new MutationObserver(mutationRecords => {
const [{attributeName}] = mutationRecords;
Expand All @@ -93,6 +95,7 @@ const AppLock: React.FC<AppLockProps> = ({
}),
);

// We log the user out if the modal is removed from the DOM
const {current: modalObserver} = useRef(
new MutationObserver(() => {
const modalInDOM = document.querySelector('[data-uie-name="applock-modal"]');
Expand Down Expand Up @@ -156,11 +159,16 @@ const AppLock: React.FC<AppLockProps> = ({
app?.style.setProperty('pointer-events', isVisible ? 'none' : 'auto', 'important');

if (isVisible) {
modalObserver.observe(document.querySelector('#wire-main'), {
childList: true,
subtree: true,
});
appObserver.observe(document.querySelector('#app'), {attributes: true});
const wireMain = document.querySelector('#wire-main');
if (wireMain) {
modalObserver.observe(wireMain, {
childList: true,
});
}
const appElement = document.querySelector('#app');
if (appElement) {
appObserver.observe(appElement, {attributes: true});
}
}
return () => {
modalObserver.disconnect();
Expand Down

0 comments on commit 0cf6a90

Please sign in to comment.