getkirby / kirby

Kirby's core application folder
https://getkirby.com
Other
1.31k stars 168 forks source link

Session timeout throws Uncaught TypeError #4373

Closed GiantCrocodile closed 2 years ago

GiantCrocodile commented 2 years ago

Description

When the timeout in the admin panel triggers, an error is thrown in the console:

Uncaught TypeError: Cannot read properties of undefined (reading 'querySelector')
    at s.focus (index.js:1:214529)
    at index.js:1:215115

Expected behavior
No error thrown.

Screenshots
grafik

To reproduce

  1. Go to admin panel and log in (checkbox for long session not ticket)
  2. switch the tab for timeout to work
  3. check console after you have been logged out/session has been cancelled

Your setup

happened with latest v3.6 release as well as with 3.7.0 rc1

Console output

Uncaught TypeError: Cannot read properties of undefined (reading 'querySelector')
    at s.focus (index.js:1:214529)
    at index.js:1:215115

Your system (please complete the following information) Windows 11 with WAMP setup

afbora commented 2 years ago

I can reproduce the issue. I think optional chaining will fix the issue.

Related issue lines

distantnative commented 2 years ago

Somehow I am too stupid to get a timeout... 😅

lukasbestle commented 2 years ago

This should do the trick to force a pretty immediate session timeout:

return [
    'session' => [
        'durationNormal' => 1,
        'durationLong'   => 1,
        'timeout'        => 1,
    ]
];
distantnative commented 2 years ago

That's what I have, but no matter how long I stay away form the Panel, once I return and click around everything just works fine, no timeout.

lukasbestle commented 2 years ago

Have you logged out and logged back in? The options only apply to new sessions.

afbora commented 2 years ago

I can reproduce the issue with following steps and options on 3.7.0. But not for develop branch. I think, we can close the issue.

Issue steps for 3.7.0

  1. Set session options with below codes
  2. Go to panel login page
  3. Open console (keep open)
  4. Delete all storage and cookies from application tab
  5. Login panel
  6. Go go any page
  7. Edit any input without save
  8. Switch the tab
  9. Wait ~15-20 seconds
  10. See error log in browser console
<?php

return [
    'debug' => true,
    'session' => [
        'durationNormal' => 15,
        'timeout'        => 5,
    ]
];
distantnative commented 2 years ago

Ahh, I was only trying with develop. But maybe then it got fixed already.

afbora commented 2 years ago

Then I'm closing the issue because it seems to be fixed already. Of course, it will reopen if reoccurs the problem.