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:
+23
-13
@@ -413,19 +413,29 @@ class KioskOverlay(QWidget):
|
|||||||
return bar
|
return bar
|
||||||
|
|
||||||
def _show_bookmarks_menu(self):
|
def _show_bookmarks_menu(self):
|
||||||
menu = self._build_menu(load_bm())
|
try:
|
||||||
menu.addSeparator()
|
menu = self._build_menu(load_bm())
|
||||||
mgr_act = QAction(" ⚙ Manage Bookmarks…", menu)
|
menu.addSeparator()
|
||||||
mgr_act.triggered.connect(self.open_manager)
|
mgr_act = QAction(" ⚙ Manage Bookmarks…", menu)
|
||||||
menu.addAction(mgr_act)
|
mgr_act.triggered.connect(self.open_manager)
|
||||||
# Explicitly position menu just below the toolbar, right-aligned.
|
menu.addAction(mgr_act)
|
||||||
# sizeHint() gives the menu's preferred width before it is painted;
|
|
||||||
# fall back to 360px if it hasn't been computed yet.
|
# The toolbar has WA_ShowWithoutActivating, so it never steals
|
||||||
mw = menu.sizeHint().width()
|
# focus from Chrome. QMenu.exec_() needs the window to be active
|
||||||
if mw < 100:
|
# to capture mouse/keyboard events; without this the menu flashes
|
||||||
mw = 360
|
# and vanishes immediately.
|
||||||
x = max(0, SCREEN_W - mw - 6)
|
self.activateWindow()
|
||||||
menu.exec_(QPoint(x, TOOLBAR_H))
|
self.raise_()
|
||||||
|
QApplication.instance().processEvents()
|
||||||
|
|
||||||
|
# Position right-aligned just below the toolbar.
|
||||||
|
mw = menu.sizeHint().width()
|
||||||
|
if mw < 100:
|
||||||
|
mw = 360
|
||||||
|
x = max(0, SCREEN_W - mw - 6)
|
||||||
|
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()
|
||||||
|
|||||||
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user