There are several threads on this same topic.
I have been having the same problem. One “solution” that has not worked is to go to System/Advanced Settings/Access and kick up the session timeout. I have mine set to SEVEN DAYS, yet I get signed out every few minutes. ¯_(ツ)_/¯
This is REALLY not a good way to encourage 2FA, TrueNAS!! ;-p If we’re going to be forced to login every 1-3 minutes, we certainly aren’t going to want to have to ALSO retried, copy, type in a 2FA code every 1-3 minutes!
PS: I don’t know if it matters, but this is happening on MacOS Safari with hardly any privacy/security countermeasures implemented. IIRC, the TrueNAS GUI didn’t play well with a locked-down Brave browser.
PPS: I think I found a possible culprit and semi-solution. If I leave the page in the foreground, Safari seems to auto-refresh when TrueNAS tries to kick me off. So, instead of coming back to a Login prompt, I just see the screen flash for a moment, and then my working page is refreshed. This at least means I don’t lose my place, but it also means that I cannot background the browser/page while I do something else. :-/