Hi, I made a server plugin to transfer pages from one server to another with rsync or sftp.
It’s working pretty good but I still have a last problem for a good integration in admin.
- I go to the page transfer (not the plugin conf, the real page transfer)
- For some reason I leave the page open a long time (mostly because I make change to files in another terminal)
- I come back and try the transfer action but login has run out of time
-And that’s the purpose : instead of coming back to the login page, it comes back to nothing but a white window (but with the debug at bottom)
and that’s all… no login box.
What do I miss ?
Not sure what the real page transfer is, but you can have different session timeout for your plugin. For example Admin plugin has a separate session timeout option from the main timeout
the “real page” is the one with the transfer logic, not the plugin configuration.
Even if it’s another session timeout, in all other peaces of the admin interface, if you reach the session timeout, you go back to the login. In my case, this is only an empty window.
Blank page usually means some errors. Did you try turning on error output? Not sure, but maybe in PHP config?
I don’t get any error (nor the grav log or php log) but probably I don’t understand exactly how it goes in admin part when you are not login.
In my case it seems that all plugins are loaded and initialised (not sure but…) before the global system check about the login.
Therefore in my plugin as I have
public function onPluginsInitialized(): void
{
if ($this->isAdmin()) {
$this->enable([
'onAdminMenu' => ['onAdminMenu', 0],
'onTwigTemplatePaths' => ['onTwigTemplatePaths', 0],
'onPagesInitialized' => ['onPagesInitialized', 0],
'onAdminTaskExecute' => ['onAdminTaskExecute', 0],
]);
}
}
it directly goes to onPagesInitializer and perform the code. Of course it fails because of a redirection to a page unreachable as the unlog blocks it.
if ($uri->path() === '/admin/pagetransfer') {
$page = new \Grav\Common\Page\Page();
$page->init(new \SplFileInfo(__DIR__ . '/pages/admin/pagetransfer.md'));
$page->template('pagetransfer'); // Use template Twig `pageTransfer.html.twig`
$this->grav['page'] = $page;
}
So I don’t know if it’s the right thing to do, but changing to this finally made the job:
public function onPluginsInitialized(): void
{
if ($this->grav['user']->authenticated && $this->isAdmin()) {
You confirm this is the right thing to do ? 
I honestly don’t know. Would require to do some researching, which unfortunately I don’t have time for currently
don’t worry. It’s anyway nice from you to answer all the time 
I’ll keep my answer as the solution for others who may need a way to do it in case of same problem. 