v0.05: fix Roundcube autologin + hamburger menu focus

Roundcube autologin fix:
- Added missing session->regenerate_id(false) and session->set_auth_cookie()
  calls after login, matching Roundcube's normal login flow in index.php.
  Without these, the roundcube_sessauth cookie was never set, causing every
  second request to fail with 'session is invalid or expired'.

Hamburger menu fix:
- Added activateWindow() + raise_() + processEvents() before menu.exec_()
  to ensure the toolbar window is active before the QMenu event loop starts.
  Without this, WA_ShowWithoutActivating prevents focus from being grabbed
  and the menu vanishes immediately.
- Added try/except to surface any silent errors.
This commit is contained in:
2026-05-21 20:29:46 -05:00
parent dfba158f3c
commit 2ca1da4f8e
2 changed files with 67 additions and 13 deletions
+13 -3
View File
@@ -413,19 +413,29 @@ class KioskOverlay(QWidget):
return bar return bar
def _show_bookmarks_menu(self): def _show_bookmarks_menu(self):
try:
menu = self._build_menu(load_bm()) menu = self._build_menu(load_bm())
menu.addSeparator() menu.addSeparator()
mgr_act = QAction(" ⚙ Manage Bookmarks…", menu) mgr_act = QAction(" ⚙ Manage Bookmarks…", menu)
mgr_act.triggered.connect(self.open_manager) mgr_act.triggered.connect(self.open_manager)
menu.addAction(mgr_act) menu.addAction(mgr_act)
# Explicitly position menu just below the toolbar, right-aligned.
# sizeHint() gives the menu's preferred width before it is painted; # The toolbar has WA_ShowWithoutActivating, so it never steals
# fall back to 360px if it hasn't been computed yet. # focus from Chrome. QMenu.exec_() needs the window to be active
# to capture mouse/keyboard events; without this the menu flashes
# and vanishes immediately.
self.activateWindow()
self.raise_()
QApplication.instance().processEvents()
# Position right-aligned just below the toolbar.
mw = menu.sizeHint().width() mw = menu.sizeHint().width()
if mw < 100: if mw < 100:
mw = 360 mw = 360
x = max(0, SCREEN_W - mw - 6) x = max(0, SCREEN_W - mw - 6)
menu.exec_(QPoint(x, TOOLBAR_H)) menu.exec_(QPoint(x, TOOLBAR_H))
except Exception as e:
print(f"Bookmarks menu error: {e}", flush=True)
def _build_menu(self, items): def _build_menu(self, items):
menu = QMenu() menu = QMenu()
+44
View File
@@ -0,0 +1,44 @@
<?php
/**
* Kiosk Auto-Login Plugin
* Automatically logs in — senior user never sees the login screen.
* Mirrors the exact session setup from index.php's normal login flow:
* login() -> session->remove('temp') -> session->regenerate_id(false)
* -> session->set_auth_cookie() -> redirect
*/
class autologin extends rcube_plugin
{
public $task = 'login';
function init()
{
$this->add_hook('startup', array($this, 'startup'));
}
function startup($args)
{
$rcmail = rcmail::get_instance();
if ($args['task'] == 'login' && empty($_SESSION['user_id'])) {
$username = 'rudbelik@gmail.com';
$password = 'zrhencfwzvgbqqfs';
$host = 'ssl://imap.gmail.com:993';
$loggedin = $rcmail->login($username, $password, $host, false);
rcube::write_log('autologin', 'Login attempt result: ' . ($loggedin ? 'SUCCESS' : 'FAILED'));
if ($loggedin) {
// Replicate exact post-login session setup from index.php
$rcmail->session->remove('temp');
$rcmail->session->regenerate_id(false);
$rcmail->session->set_auth_cookie();
header('Location: ' . $rcmail->url(array('_task' => 'mail')));
exit;
}
}
return $args;
}
}